blob: 4372d4460b8ccb78abcedea829a2171d6ecf774c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#include <stdio.h>
void copy_comment()
{
int c;
while ((c = getchar()) != EOF) {
if (c == '*') {
if ((c = getchar()) == '/') {
putchar('\n');
return;
}
if (c != EOF)
ungetc(c, stdin);
putchar('*');
} else {
putchar(c);
}
}
}
void skip_string(int quote)
{
int c;
while ((c = getchar()) != EOF) {
if (c == quote) {
return;
} else if (c == '\\') {
getchar();
}
}
}
int main()
{
int c;
while ((c = getchar()) != EOF) {
switch (c) {
case '/':
if ((c = getchar()) == '*') {
copy_comment();
} else if (c == '/') {
while ((c = getchar()) != EOF) {
putchar(c);
if (c == '\n')
break;
}
} else {
if (c != EOF)
ungetc(c, stdin);
}
break;
case '"':
case '\'':
skip_string(c);
break;
case '\\':
(void) getchar();
break;
default:
break;
}
}
}
|