61 lines
1.5 KiB
C
61 lines
1.5 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_main.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: lvincent <lvincent@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/07/31 15:11:39 by julemart #+# #+# */
|
|
/* Updated: 2022/07/31 23:24:25 by lvincent ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "rush02.h"
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
char **tab_line;
|
|
int i;
|
|
char *nbr;
|
|
struct s_nb *line;
|
|
|
|
if (argc == 3)
|
|
{
|
|
tab_line = ft_dict_to_line(argv[1]);
|
|
nbr = argv[2];
|
|
}
|
|
if (argc == 2)
|
|
{
|
|
tab_line = ft_dict_to_line("numbers.dict.txt");
|
|
nbr = argv[1];
|
|
}
|
|
if (argc <= 3 && argc > 1)
|
|
{
|
|
if (!ft_parse(nbr))
|
|
{
|
|
ft_error();
|
|
return (0);
|
|
}
|
|
ft_trim(nbr);
|
|
while (tab_line[i])
|
|
{
|
|
i++;
|
|
}
|
|
line = malloc(sizeof(struct s_nb) * i);
|
|
i = 0;
|
|
while (tab_line[i])
|
|
{
|
|
line[i] = ft_parse_line(tab_line[i]);
|
|
i++;
|
|
}
|
|
while (tab_line[i])
|
|
{
|
|
free(tab_line[i]);
|
|
i++;
|
|
}
|
|
free(line);
|
|
free(tab_line);
|
|
}
|
|
return (0);
|
|
}
|