Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main()
- {
- freopen("program_with_comments.c", "r", stdin);
- freopen("output.c", "w", stdout);
- char c;
- int state = 0;
- while ((c = getchar()) != EOF)
- {
- switch(state)
- {
- case 0:
- if (c == '/')
- state = 1;
- else if (c == '"')
- state = 4;
- break;
- case 1:
- if (c == '*')
- state = 2;
- else
- state = 0;
- break;
- case 2:
- if (c == '*')
- state = 3;
- break;
- case 3:
- if (c == '/') {
- state = 0;
- continue;
- }
- else if (c != '*')
- state = 2;
- break;
- case 4:
- if (c == '"')
- state = 0;
- break;
- }
- if (state == 0 || state == 4)
- putchar(c);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement