c - Comments(/*...*/) longer than one line -
i supposed count /*...*/
comments in file , wondering if code
right or missing out?
my code
void commentslongerthanoneline(file* inputstream, file* outputstream) { int count = 0, c, state = 1; while ((c = fgetc(inputstream) != eof)) { switch (state) { case 1: switch (c) { case '/': state = 2; break; } break; case 2: switch (c) { case '/': state = 3; break; case '*': state = 4; break; default: state = 1; } break; case 3: switch (c) { case '\n': state = 1; break; default: state = 4; count++; } break; case 4:switch (c) { case'*': if (c == '\n') count++; break; default: state = 4; if (c == '\n') count++; } } } fprintf(outputstream, "comments longer 1 line: %d\n", count); }
Comments
Post a Comment