[word_class.c]

#include <stdio.h>
int main(void)
{
    int c, i, nwhite, nother;
    int ndigit;
    nwhite = nother = 0;
    for (i = 0; i < 10; i++)
        ndigit[i] = 0;
    while ((c = getchar()) != EOF)
        if (c >= '0' && c <= '9')
            ndigit[c - '0']++;   
        else if (c == ' ' || c == '\n' || c == '\t')
            ++nwhite;
        else
            ++nother;
    printf("digit = ");
    for (i = 0; i < 10; i++)
        printf(" %d", ndigit[i]);
    printf(",white space = %d, other = %d\n", nwhite, nother);
}

[test.txt]
01234567989

실행 결과:
word_class < test.txt
digit =  1 1 1 1 1 1 1 1 1 2,white space = 0, other = 0

tcpl에 있는 단어 분류하는 예제인데 왜 9가 두번나온다고 하는건지 모르겠음..