1234567891011121314151617181920212223242526 |
- #include <stdio.h>
- int
- main () {
- //Variables for blanks, tabs, and newlines
- int b, t, n = 0;
- int c;
- // Loop through the input, and add up all of
- // the blanks, tabs, and newlines
- while ((c = getchar ()) != EOF) {
- switch (c) {
- case '\n':
- n += 1;
- break;
- case '\t':
- t += 1;
- break;
- case ' ':
- b += 1;
- break;
- }
- }
- // print the results
- printf("There are %d blanks, %d tabs, and %d newlines.\n", b, t, n);
- }
|