norme, fix name of numeric check

This commit is contained in:
Aleksei Chubukov 2023-12-03 18:09:56 +04:00
parent a5c0814aa3
commit f0bc88b8ec
3 changed files with 21 additions and 6 deletions

View File

@ -6,7 +6,7 @@
/* By: achubuko <marvin@42.fr> +#+ +:+ +#+ */ /* By: achubuko <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/02 21:56:30 by achubuko #+# #+# */ /* Created: 2023/12/02 21:56:30 by achubuko #+# #+# */
/* Updated: 2023/12/03 18:03:15 by asargsya ### ########.fr */ /* Updated: 2023/12/03 18:07:15 by achubuko ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "ft_utils.h" #include "ft_utils.h"
@ -25,6 +25,7 @@ size_t ft_strlen(char *s)
l++; l++;
return (l); return (l);
} }
int ft_str_is_numeric(char *str) int ft_str_is_numeric(char *str)
{ {
int i; int i;

View File

@ -6,7 +6,7 @@
/* By: achubuko <marvin@42.fr> +#+ +:+ +#+ */ /* By: achubuko <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/02 21:57:06 by achubuko #+# #+# */ /* Created: 2023/12/02 21:57:06 by achubuko #+# #+# */
/* Updated: 2023/12/02 23:04:09 by achubuko ### ########.fr */ /* Updated: 2023/12/03 18:08:38 by achubuko ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#ifndef FT_UTILS_H #ifndef FT_UTILS_H
@ -16,4 +16,5 @@
uint32_t ft_atoui32(char *str); uint32_t ft_atoui32(char *str);
size_t ft_strlen(char *s); size_t ft_strlen(char *s);
int ft_str_is_numeric(char *str);
#endif #endif

View File

@ -6,7 +6,7 @@
/* By: achubuko <marvin@42.fr> +#+ +:+ +#+ */ /* By: achubuko <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/02 21:01:21 by achubuko #+# #+# */ /* Created: 2023/12/02 21:01:21 by achubuko #+# #+# */
/* Updated: 2023/12/02 23:45:57 by achubuko ### ########.fr */ /* Updated: 2023/12/03 18:09:34 by achubuko ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "main.h" #include "main.h"
@ -18,5 +18,18 @@ int main(int argc, char **argv)
write(1, "Error: program requires 1 or 2 arguments passed!", 48); write(1, "Error: program requires 1 or 2 arguments passed!", 48);
return (1); return (1);
} }
write(1, argv[1], ft_strlen(argv[1])); if (ft_str_is_numeric(argv[1]) == 1)
{
print_digit_words(argv[1]);
}
else if (ft_str_is_numeric(argv[1]) == -1)
{
write(1, "Argument #1 must be positive!", 28);
return (2);
}
else
{
write(1, "Argument #1 must be a number!", 28);
return (3);
}
} }