This repository has been archived on 2021-10-31. You can view files and clone it, but cannot push or open issues or pull requests.
sys_prog/shellcomments.c

25 lines
400 B
C

#include <stdio.h>
#include <stdbool.h>
int main(int argc, char const *argv[]) {
int c;
bool is_comment;
while ((c = getchar()) != EOF) {
if (c == '#') {
is_comment = true;
} else if (c != '\n' && is_comment) {
putchar(c);
} else if (c == '\n' && is_comment) {
putchar('\n');
is_comment = false;
} else {
// do nothing
}
}
return 0;
}