-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_input.c
36 lines (34 loc) · 1.26 KB
/
check_input.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_input.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cosney <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/24 04:53:38 by cosney #+# #+# */
/* Updated: 2020/04/24 05:19:42 by cosney ### ########.fr */
/* */
/* ************************************************************************** */
int check_input(int argc, char **argv, int k)
{
int i;
i = 0;
if (argc != 2)
return (1);
while (i < (8 * k - 1))
{
if (argv[1][i] < '1' || argv[1][i] > (k + '0'))
return (1);
i = i + 2;
}
i = 1;
while (i < (8 * k - 1))
{
if (argv[1][i] != ' ')
return (1);
i = i + 2;
}
if (argv[1][8 * k - 1] != '\0')
return (1);
return (0);
}