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>
- int main()
- {
- int nb, nt, nl, c;
- nb = nt = nl = 0;
- while ((c = getchar()) != EOF) {
- if (c == ' ') nb++;
- else if (c == '\t') nt++;
- else if (c == '\n') nl++;
- }
- printf ("nb = %d\t nt = %d\t nl = %d", nb, nt, nl);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment