-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5-options.c
50 lines (48 loc) · 1.01 KB
/
5-options.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
#include <unistd.h>
int main(int ac, char **av)
{
int i = 1;
int t[32] = {0};
int j;
if (ac == 1)
{
write(1, "options: abcdefghijklmnopqrstuvwxyz\n", 36);
return 0;
}
i = 1;
while (i < ac)
{
j = 1;
if (av[i][0] == '-')
{
while (av[i][j] && av[i][j] >= 'a' && av[i][j] <= 'z')
{
if (av[i][j] == 'h')
{
write(1, "options: abcdefghijklmnopqrstuvwxyz\n", 36);
return 0;
}
t['z' - av[i][j] + 6] = 1;
j++;
}
if (av[i][j])
{
write(1, "Invalid Option\n", 15);
return 0;
}
j++;
}
i++;
}
i = 0;
while (i < 32)
{
t[i] = '0' + t[i];
write(1, &t[i++], 1);
if (i == 32)
write(1, "\n", 1);
else if (i % 8 == 0)
write (1, " ", 1);
}
return 0;
}