#include #include int main(void){ char rida[128]; int i, j, len, sone = 0, c_area = 0; FILE *sisse=fopen("sourcecode.dat", "r"); FILE *valja=fopen("result.dat", "w"); while(!feof(sisse)){ fgets(rida, 128, sisse); //Eemaldab kommenteeritud alad if (strstr(rida, "//") || strstr(rida, "/*") || strstr(rida, "*/") || c_area == 1){ len = strlen(rida); i = 0; while(i < (len - 1)){ j = i + 1; //Sõnes olevate kommentaaride mitte arvestamine if (rida[i] == '"'){ if (sone == 0){ sone = 1; } else { sone = 0; } } if (rida[i] == '/' && rida[j] == '*' && sone == 0){ i = i + 2; c_area = 1; if (i >= (len - 1)){ break; } } if (rida[i] == '*' && rida[j] == '/' && sone == 0){ i = i + 2; c_area = 0; if (i >= (len - 1)){ break; } } if (rida[i] == '/' && rida[j] == '/' && sone == 0){ break; } //Väljasta tekst kui tegu ei ole kommentaariga if (c_area != 1){ fprintf(valja, "%c", rida[i]); } i++; } } // Väljastab kommentaarideta rea else { fprintf(valja, "%s", rida); } } fclose(sisse); fclose(valja); printf("\n\n"); system("pause"); return 0; }