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

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -