Blob


1 /*
2 1-8. Write a program to count blanks, tabs, and newlines.
3 1-9. Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank.
4 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.
5 */
7 #include <stdio.h>
9 main()
10 {
11 int c, blanks, tabs, nl;
13 blanks = 0, tabs = 0, nl = 0;
14 while ((c = getchar()) != EOF) {
15 if (c == '\n') {
16 ++nl;
17 } else if (c == '\t') {
18 ++tabs;
19 } else if (c == ' ') {
20 ++blanks;
21 }
22 }
23 printf("blanks: %d, tabs: %d, newlines: %d\n", blanks, tabs, nl);
24 }