started on 1-13
[KandRexercises.git] / charreplace.c
blob153c35be9722e2a4cc4e935fa9668934c0aeed3f
1 #include <stdio.h>
2 /* exercise 1-10: replace, \, backspace and tab characters */
4 main() {
5 int c;
6 while((c = getchar()) != EOF) {
8 if(c == '\t') {
9 putchar('\\');
10 putchar('t');
11 } else if(c == '\\') {
12 putchar('\\');
13 putchar('\\');
14 } else if(c == '\b') {
15 putchar('\\');
16 putchar('b');
17 } else {
18 putchar(c);
22 putchar('\n');