mise en place des fichiers

This commit is contained in:
hugogogo
2021-06-11 19:32:36 +02:00
parent 64363aeb18
commit 9ddf8ab304
11 changed files with 94 additions and 37 deletions

View File

@@ -6,27 +6,49 @@ void is_valid(int ac, char **av)
if (ac < 2)
ps_error(1);
(void)av;
// check more error
}
t_stack *init_stack(int ac, char **av)
{
(void)ac;
(void)av;
t_stack *start;
t_stack *tmp;
if (!(start = ft_calloc(1, sizeof(t_stack))))
ps_clean(start, 2);
tmp = NULL;
while (--ac)
{
if (!(start = ft_calloc(1, sizeof(t_stack))))
ps_clean(start, 2);
start->n = ft_atoi(av[ac]);
start->next = tmp;
tmp = start;
}
return (start);
}
void print_stack(t_stack *stack)
{
ft_putstr("[");
while (stack)
{
ft_printf("%i", stack->n);
stack = stack->next;
if (stack)
ft_putstr("; ");
}
ft_putstr("]\n");
}
int main(int ac, char **av)
{
t_stack *stack;
//t_list *result;
t_list *result;
is_valid(ac, av); // check if usage and list are correct
stack = init_stack(ac, av);
// result = sort_algo(stack);
stack = init_stack(ac, av); // create the list from av[]
print_stack(stack);
result = sort_algo(stack);
ft_printf("%s\n", result->content);
ps_clean(stack, 1);
return(0);
}