Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Exercise 1-8.
- * Write a program to count blanks, tabs, and newlines.
- */
- #include <stdio.h>
- main() {
- int c;
- long blanks, tabs, lines;
- blanks = tabs = lines = 0;
- while ((c = getchar()) != EOF) {
- if (c == ' ')
- ++blanks;
- if (c == '\t')
- ++tabs;
- if (c == '\n')
- ++lines;
- }
- printf("blanks = %ld, tabs = %ld, newlines = %ld\n",
- blanks, tabs, lines);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement