-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_param.c
73 lines (66 loc) · 1.68 KB
/
check_param.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
65
66
67
68
69
70
71
72
73
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_param.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rgiraud <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/13 18:55:21 by htassain #+# #+# */
/* Updated: 2023/08/13 19:11:27 by rgiraud ### ########.fr */
/* */
/* ************************************************************************** */
void ft_rush_main(int tab_config[4][4]);
int ft_strlen(char *str)
{
int i;
i = 0;
while (str[i] != '\0')
i++;
return (i);
}
int ft_check_argv(char **argv)
{
int i;
i = 0;
while (argv[1][i] != '\0')
{
if (argv[1][i] >= '1' && argv[1][i] <= '4' && (i % 2 == 0))
{
i++;
}
else if (argv[1][i] == ' ' && (i % 2 == 1))
i++;
else
{
return (0);
}
}
return (1);
}
int ft_check_param(int i, int j, int argc, char **argv)
{
int k;
int tab_config[4][4];
if (argc == 2 && ft_strlen(argv[1]) == 31 && ft_check_argv(argv))
{
k = 0;
while (argv[1][i] != '\0')
{
if (k > 3)
{
j++;
k = 0;
}
if (argv[1][i] >= '1' && argv[1][i] <= '4')
{
tab_config[j][k] = argv[1][i] - 48;
k++;
}
i++;
}
ft_rush_main(tab_config);
return (1);
}
else
return (0);
}