This repository has been archived on 2023-12-28. You can view files and clone it, but cannot push or open issues or pull requests.
c_piscine_rush_02/ex00/main.c
Aleksei Chubukov b5efa9ea07 unfinished
2023-12-03 23:36:55 +04:00

49 lines
1.5 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rush-02.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: achubuko <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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]);
if (!chk)
print_digit_words(argv[1]);
else
return (chk);
}