-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchararithmetictest.c
78 lines (62 loc) · 1.35 KB
/
chararithmetictest.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
74
75
76
77
78
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int var_assignment_validator(char* line){
int t = 0;
char eql = '=';
if (strchr(line,eql)){
t = 1;
}
}
typedef struct variable{
int size;
char var_name[MAX_VAR_LEN];
char scope[MAX_NAME_LEN];
char type[MAX_TYPE_LEN];
struct var_struct *next;
} VAR;
VAR variable_parser(char* line){
VAR parse_var;
}
int alloc_validator(char* line){
int t = 0;
char mall[] = "malloc(";
char call[] = "calloc(";
if (strstr(line, mall)){
t = 1;
}
else if(strstr(line, call)){
t = 1;
}
return t;
}
int ifloops_validator(char* line){
int t = 0;
char ifword[] = "if (";
char forword[] = "for(";
char whileword[] = "while(";
if (strstr(line, ifword)){
t = 1;
}
else if(strstr(line, forword)){
t = 1;
}
else if(strstr(line, whileword)){
t = 1;
}
return t;
}
int main(int argc, char** argv){
//fgets reutrns the pointer back if it was successful reading the line, otherwise null;
FILE * fp = fopen(argv[1],"r");
char line_code[256];
// char parsed[256];
int x;
if (fgets(line_code, 256, fp) == NULL){
fclose(fp);
exit(1);
}
fclose(fp);
// sscanf(line_code, "int %[^;]", parsed);
printf("%d\n", x);
}