-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunitest-log.c
More file actions
58 lines (51 loc) · 831 Bytes
/
unitest-log.c
File metadata and controls
58 lines (51 loc) · 831 Bytes
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
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
int main(void) {
FILE* log_file;
log_file = fopen("logfile.txt", "r");
char line[BUFSIZ];
int i, value = 0;
if (log_file == NULL)
{
printf("Error opening log file.\n");
}
fgets(line, BUFSIZ, log_file);
for (i = 1; line[i] != '\n'; i++)
{
while (i < 18)
{
if (isdigit(line[i]))
{
i += 1;
}
else
{
printf("Fault in log file.\n");
exit(1);
}
if (i == 3 || i == 6 || i == 11 || i == 14 || i == 17)
{
i += 1;
}
}
}
if (line[22] == 'T')
{
if (isdigit(line[35]))
{
printf("Log file oke.");
}
else
{
printf("Fault in log file.");
exit(1);
}
}
else
{
printf("Fault in log file.");
exit(1);
}
fclose(log_file);
}