the-c-programming-language/chapter01/ex08.c (299B)
1 2 3 4 #include <stdio.h> 5 6 7 int main( void ) { 8 9 10 int c, bl, tb, nl; 11 bl = tb = nl = 0; 12 13 while((c = getchar()) != EOF) { 14 if (c == ' ') 15 bl++; 16 else if (c == '\t') 17 tb++; 18 else if (c == '\n') 19 nl++; 20 } 21 22 printf("Blanks\t\t=\t%d\nTabs\t\t=\t%d\nNewlines\t=\t%d\n", bl, tb, nl); 23 return 0; 24 }