learningc/chapters/1/exercises/8.c

19 lines
375 B
C

#include <stdio.h>
int main() {
int c, tabc, blankc, nl;
tabc = blankc = nl = 0;
while ((c = getchar()) != EOF) {
if (c == '\t') {
tabc++;
} else if (c == ' ') {
blankc++;
} else if (c == '\n') {
nl++;
}
}
printf ("\nSpecial character count:\n");
printf ("Newlines: %d\nBlanks: %d\nTabs: %d\n", nl, blankc, tabc);
return 0;
}