Miscellany
public text v1 · immutable#include <stdio.h>
/* remove comments from C source */
main()
{
char c, lc;
int incom;
while ((c = getchar()) != EOF) {
if (incom == 1) {
if (lc == '*' && c == '/') {
incom = 0;
}
}
else if (c == '/') {
} /* eh? */
else if (lc == '/' && c == '*') {
incom = 1;
}
/* else if (lc == '/' && c != '*') {
printf("HMMM");
} */
else if (lc == '/' && incom == 0 && c != '*') {
printf("%c%c", lc, c);
}
else {
printf("%c", c);
}
lc = c;
}
}