-
Notifications
You must be signed in to change notification settings - Fork 4
/
exercise1-10.c
49 lines (43 loc) · 828 Bytes
/
exercise1-10.c
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
#include <stdio.h>
int main(void)
{
int c, replaced;
while((c = getchar()) != EOF) {
replaced = 0;
if (c == '\t') {
putchar('\\');
putchar('t');
replaced = 1;
}
if (c == '\b') {
putchar('\\');
putchar('b');
replaced = 1;
}
if (c == '\\') {
putchar('\\');
putchar('\\');
replaced = 1;
}
if (replaced == 0)
putchar(c);
}
return 0;
}
/*
int main(void)
{
int c;
while ((c = getchar()) != EOF) {
if (c == '\t')
printf("\\t");
else if (c == '\b')
printf("\\b");
else if (c == '\\')
printf("\\\\");
else
putchar(c);
}
return 0;
}
*/