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

/*
 * Count whitespace in input
 */
main() {
    int c, n_whitespace;

    n_whitespace = 0;

    while ((c = getchar()) != EOF) {
        if (c == '\n')
            ++n_whitespace;
        if (c == '\t')
            ++n_whitespace;
        if (c == ' ')
            ++n_whitespace;
    }


    printf("%d\n", n_whitespace);
}