aboutsummaryrefslogtreecommitdiff
path: root/1/10.c
blob: 0b2d0aea838da4dd2496b8a7518a51d289a4d44b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
	Exercise 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.
	===
*/

#include <stdio.h>

int main () {
	int c;

	while ((c=getchar())!=EOF) {
		if (c=='\t') { printf("\\t");	continue; }	/* tab */
		if (c=='\b') { printf("\\b");	continue; }	/* backspace */
		if (c=='\\') { printf("\\\\");	continue; }	/* backslash */
		putchar(c);	/* other */
	}
}