#include<stdio.h> #include<string.h> #define size 100 int compare(char *line); int main() { file *codefile, *list; //file *codefile; char chset[size], *codeline, filename[size]; //char *chset, *codeline; int i=0, counter=0; /*introduction message*/ printf("\t================================================================ ============\n"); printf("\tthis is the program of counting number of webpage wroted in thai language.\n"); printf("\tauthored by aesah hayeemad 3coe prince of songkhla university\n"); printf("\tsupervisor : dr. aree theerapaabsearee\n"); printf("\tenjoy this program now! (hope you like it!)\n"); printf("\t================================================================ ============\n"); list=fopen("list.txt","r"); if(list!=null) { fscanf(list,"%s",filename); while(!feof(list)) { if(filename==null) { printf("error"); exit(1); } if(filename!=null) { codefile=fopen(filename,"r"); if(codefile==null) printf("error read file!"); else { fscanf(codefile,"%s",chset); while(!feof(codefile)) { if(compare(chset)) counter++; fscanf(codefile,"%s",chset); } } }
fclose(codefile); //if filename
fscanf(list,"%s",filename); }//while fclose(list); printf("\n\tthis is counter = %d\n\n",counter);
}
} return 0;
int compare(char *line) { /*char c_line[size]; c_line=line;*/ if (strstr(line,"tis-620")!=null) return 1; else if (strstr(line,"windows-874")!=null) return 1; //else if (strstr(line,"utf-8")) //return 1; else if (strstr(line,"iso-8859-11")!=null) return 1; else return 0; }