P#14 统计行数、单词数与字符数

#include <stdio.h>

int main() {

    int nc = 0, nw = 0, nl = 0, c;
    //nc number of count
    //nw number of word
    //nl number of line

    while((c = getchar()) != EOF) {
        ++ nc;
        switch(c) {
            case '\n' :
                ++ nl;
            case ' ' :
            case '\t' :
                ++ nw;
                break;
        }
    }

    printf("line: %d  word: %d  count: %d\n", nl, nw, nc);
    return 0;
}