Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void skipLineComm() {
- for (char ch; (ch = getchar()) != EOF;) {
- if (ch == '\n') {
- putchar('\n');
- return;
- }
- }
- }
- void skipBlockComm() {
- for (char ch, last = 0; (ch = getchar()) != EOF; last = ch) {
- if (ch == '/' && last == '*') {
- return;
- }
- }
- }
- int main(void) {
- for (char ch, last = 0; (ch = getchar()) != EOF; last = ch) {
- if (ch == '/' && last != '/') {
- continue;
- }
- if (ch == '/' && last == '/') {
- skipLineComm();
- ch = last = 0;
- }
- if (ch == '*' && last == '/') {
- skipBlockComm();
- ch = last = 0;
- }
- if (last == '/') {
- putchar(last);
- }//*/
- putchar(ch);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement