-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathminor.c
61 lines (49 loc) · 1.8 KB
/
minor.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<stdio.h>
int system(const char *); // //to invoke any operating system commands
char s[100];
void input_user(); //input function
void predict(); //to predict errors and warnings
void print_file(char *); //to display the contents of various log files
void output(); //to display the output of the user code
int main(){
input_user(); //calling input function
predict(); //calling the predict function
output(); //calling the output function
return 0;
}
void input_user(){ //to input user code
FILE *fp; //input will be stored in a .c file
fp=fopen("userdata.c","w");
while(scanf("%[^~]",s)==1){ //for taking multi line input and fusing "~" as delimiter
fprintf(fp,"%s",s); //for writing the input in the file
}
fclose(fp);
}
void predict(){
system("gcc userdata.c 2> logsgcc.txt -o userdata");
system("cppcheck userdata.c 2> logcpp.txt");
system("splint userdata.c -streamoverwrite +message-stream logssplintmsg.txt +warning-stream logssplintwarn.txt +error-stream logsplinterr.txt");
printf("\nCompilation error:\n");
print_file("logsgcc.txt"); //Function to print log file created by gcc compiler
printf("\nIn a easy way:\n");
print_file("logsplinterr.txt"); //Function to print error-log file by splint
printf("\nCode improvemnets: \n");
print_file("logssplintwarn.txt"); //Function to print warning-log file by splint
printf("\nError Predictions: \n");
print_file("logcpp.txt"); //function to print log file by cppcheck
printf("\nAny extra remarks: \n");
print_file("logssplintmsg.txt"); //function to print any extra warnings
}
void print_file(char *name){
FILE *fp;
fp=fopen(name,"r");
while(fgets(s,99,fp)!=NULL){
printf("%s",s);
}
fclose(fp);
}
void output(){ //output of the user code
printf("\nOutput: \n");
system("./userdata");
printf("\n");
}