/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* rush-02.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: achubuko +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/12/02 21:01:21 by achubuko #+# #+# */ /* Updated: 2023/12/03 22:21:05 by achubuko ### ########.fr */ /* */ /* ************************************************************************** */ #include "main.h" int invalid_arg_num(char *arg) { if (ft_str_is_numeric(arg) == 0) { write(1, "Argument #1 must be a number!\n", 29); return (3); } else if (ft_str_is_numeric(arg) == -1) { write(1, "Argument #1 must be positive!\n", 29); return (2); } else return (0); } int main(int argc, char **argv) { int chk; t_dict *d; if (argc <= 1 || argc > 3) { write(1, "Error: program requires 1 or 2 arguments passed!\n", 49); return (1); } d = dict_create_default("numbers.dict"); if (argc == 3) dict_update(d, argv[2]); chk = invalid_arg_num(argv[1]); t_file *file = ft_open(argv[1]); ft_buffer_line(file); printf("%s\n", file->buffer); if (!chk) print_digit_words(argv[1]); else return (chk); }