Blame


1 5dc21454 2023-07-14 jrmu /*
2 5dc21454 2023-07-14 jrmu 1-10. Write a program to copy its input to its output, replacing each tab by \t, each backspace by \b, and each backslash by \\. This makes tabs and backspaces visible in an unambiguous way.
3 5dc21454 2023-07-14 jrmu */
4 5dc21454 2023-07-14 jrmu
5 5dc21454 2023-07-14 jrmu #include <stdio.h>
6 5dc21454 2023-07-14 jrmu
7 5dc21454 2023-07-14 jrmu main()
8 5dc21454 2023-07-14 jrmu {
9 5dc21454 2023-07-14 jrmu int c;
10 5dc21454 2023-07-14 jrmu
11 5dc21454 2023-07-14 jrmu while ((c = getchar()) != EOF) {
12 5dc21454 2023-07-14 jrmu if (c == '\t') {
13 5dc21454 2023-07-14 jrmu printf("\\t");
14 5dc21454 2023-07-14 jrmu } else if (c == '\b') {
15 5dc21454 2023-07-14 jrmu printf("\\b");
16 5dc21454 2023-07-14 jrmu } else if (c == '\\') {
17 5dc21454 2023-07-14 jrmu printf("\\\\");
18 5dc21454 2023-07-14 jrmu } else {
19 5dc21454 2023-07-14 jrmu printf("%c", c);
20 5dc21454 2023-07-14 jrmu }
21 5dc21454 2023-07-14 jrmu }
22 5dc21454 2023-07-14 jrmu }