From f0bc88b8ecb1c6c01c6404cb4bdaf17b8a6373ca Mon Sep 17 00:00:00 2001 From: Aleksei Chubukov Date: Sun, 3 Dec 2023 18:09:56 +0400 Subject: [PATCH] norme, fix name of numeric check --- ex00/ft_utils.c | 7 ++++--- ex00/ft_utils.h | 3 ++- ex00/main.c | 17 +++++++++++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ex00/ft_utils.c b/ex00/ft_utils.c index 0db80a1..c0e3e67 100644 --- a/ex00/ft_utils.c +++ b/ex00/ft_utils.c @@ -6,7 +6,7 @@ /* 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" @@ -25,9 +25,10 @@ size_t ft_strlen(char *s) l++; return (l); } -int ft_str_is_numeric(char *str) + +int ft_str_is_numeric(char *str) { - int i; + int i; i = 0; if (str[i] == '\0') diff --git a/ex00/ft_utils.h b/ex00/ft_utils.h index 8e5d9ba..f82d180 100644 --- a/ex00/ft_utils.h +++ b/ex00/ft_utils.h @@ -6,7 +6,7 @@ /* 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 @@ -16,4 +16,5 @@ uint32_t ft_atoui32(char *str); size_t ft_strlen(char *s); +int ft_str_is_numeric(char *str); #endif diff --git a/ex00/main.c b/ex00/main.c index babb3c2..c08984f 100644 --- a/ex00/main.c +++ b/ex00/main.c @@ -6,7 +6,7 @@ /* 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" @@ -18,5 +18,18 @@ int main(int argc, char **argv) write(1, "Error: program requires 1 or 2 arguments passed!", 48); 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); + } }