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
| #define bufSize 2000
void make_filter(char *file){
FILE *fp ;
fp=fopen(file,"r");
char buf[bufSize];
int count ;
int i ;
FILE *final ;
final=fopen("zoo.txt","a");
count=make_count(filename); // count the number of lines
while(fgets(buf,bufSize,fp)!=NULL){
buf[strlen(buf)-1]='\0';
if (strstr(buf,"<date>")!=NULL){
if (strstr(buf,"<hour>")!=NULL){
if (strstr(buf,"<machine>")!=NULL){
if (strstr(buf,"<line>")!=NULL){
if (strstr(buf,"<message>")!=NULL){
if (strstr(buf,"</event>")){
fprintf(final, "%s\n",buf);
}
}
}
}
}
}
}
fclose(final);
fclose(fp);
} |
Partager