-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
63 lines (58 loc) · 1.65 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: arasal <arasal@student.42heilbronn.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/24 17:48:45 by arasal #+# #+# */
/* Updated: 2022/06/22 22:16:59 by arasal ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
static void check_strings(int argc, char **argv)
{
char **a;
unsigned int i;
unsigned int j;
i = 1;
while (i < (unsigned int)argc)
{
j = 0;
a = ft_split(argv[i], ' ');
while (a[j] != NULL)
{
if (ft_strlen(a[j]) > 11)
{
deletestr(a);
atoierror();
}
j++;
}
deletestr(a);
i++ ;
}
}
int main(int argc, char **argv)
{
t_stack *a;
t_stack *b;
char **arg;
t_stats *st;
int i;
i = 1;
a = NULL;
b = NULL;
st = NULL;
check_strings(argc, argv);
check_empty_input(argc, argv);
arg = split_strings(&argc, &argv);
while (++i <= argc)
{
checkrepeat(ft_atoi_(arg[i - 1], a, st, arg), a, st, arg);
save(ft_atoi_(arg[i - 1], a, st, arg), &a);
save_stats(ft_atoi(arg[i - 1]), &st);
}
algorithm(&a, &b, &st, arg);
return (0);
}