-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
64 lines (57 loc) · 1.53 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
64
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: admansar <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/13 17:53:54 by admansar #+# #+# */
/* Updated: 2023/03/29 22:43:29 by admansar ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
unsigned long counter_space(char *c)
{
int i;
i = 0;
while (c[i] == ' ')
i++;
return (i);
}
void init_errors(int ac, char **av)
{
int i;
i = ac;
while (i--)
{
if (!ft_strlen(av[i]))
{
write(2, "Error\n", ft_strlen("Error\n"));
exit(1);
}
}
while (++i < ac)
{
if (ft_strlen(av[i]) == counter_space(av[i]))
{
write(2, "Error\n", ft_strlen("Error\n"));
exit(1);
}
}
}
int main(int ac, char **av)
{
char **a;
char **b;
if (ac == 1)
exit(0);
init_errors(ac, av);
av = split_args(av);
a = words(av);
ft_error(a);
b = ft_calloc(1, sizeof(char *));
push_swap(a, b);
free(a);
free(b);
return (0);
}