diff --git a/shellcomments.c b/shellcomments.c new file mode 100644 index 0000000..84cd95c --- /dev/null +++ b/shellcomments.c @@ -0,0 +1,24 @@ +#include +#include + +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; +}