-
Notifications
You must be signed in to change notification settings - Fork 0
/
handlers.c
61 lines (53 loc) · 794 Bytes
/
handlers.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
#include <unistd.h>
void error(void)
{
write(1, "Error", 6);
}
void printchar(char a)
{
write(1, &a, 1);
}
void check_if_number(char *input)
{
int counter;
char *output;
counter = 0;
while (input[counter] != '\0')
{
if (input[counter] >= '1' && <= '9')
{
output[counter] = input[counter];
counter++;
}
else if (input[counter] == ' ')
counter++;
else
{
error();
break ;
}
}
char_to_int_conversion(output);
}
void char_to_int_conversion(char *str)
{
int *converted;
int index;
while (str[index] != '\0')
{
converted[index] = str[index] + 48;
index++;
}
set_rows_and_columns(str);
}
void set_rows_and_columns(char *str)
{
int index;
index = 0;
while (str[index] != '\0')
{
index++;
}
index = index / 4;
matrix(index, index, str);
}