1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include <string.h>

void remove_comment(const char* s) {
  const char* cs;
  while ((cs = strstr(s, "/*")) != NULL) {
    fwrite(s, 1, cs - s, stdout);
    if ((s = strstr(cs, "*/")) == NULL)
      return;
    s += 2;
  }
  printf("%s\n", s);
}

main() {
  remove_comment("AAA");
  remove_comment("AAA/*BBB*/");
  remove_comment("AAA/*BBB");
  remove_comment("AAA/*BBB*/CCC");
  remove_comment("AAA/*BBB/*CCC*/DDD*/EEE");
  remove_comment("AAA/a//*BB*B**/CCC");
}