// --- file coments.c ------------ #include #include "coments.h" /* --- main() --- */ int main() { //--- definition part --- int c; int brC=0; int brCpp=0; enum coment_sta state=None; //--- automat status -- FILE *f; char name_file[81]; /* --- end definition part */ /* ---- */ //----- statement part printf("type name input file:"); do { c=scanf("%s",name_file); }while(c!=1); f=fopen( name_file,"rt"); if(f==NULL) { printf("No such file\n"); return 2; } while((c = fgetc(f)) != EOF) { state=compute_coments(c, state); if(state==End_C) brC++; if(state==End_Cpp) brCpp++; } fclose(f); printf( "found %d c and %d c++ comments\n", brC,brCpp); return 0; } //--- end program --------