summaryrefslogtreecommitdiffstats
path: root/1/8.c
blob: 400a2de5b1fc4704be7a3a1827c8e8c837278a54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>

/* counts blanks, tabs and newlines in input */
int main(int argc, char *argv[]) {
  int c, bc, tc, nc;

  bc = tc = nc = 0;

  while ((c = getchar()) != EOF) {
    if (c == ' ')
      bc++;
    else if (c == '\t')
      tc++;
    else if (c == '\n')
      nc++;
  }

  printf("blanks: %d, tabs: %d, newlines: %d\n", bc, tc, nc);
  return 0;
}