[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가 두번나온다고 하는건지 모르겠음..
나이수
입력파일내용을 잘 봐ㅋㅋㅋㅋ 근데 저거 소스 컴파일 됨?
아 뭔데 ㅋㅋㅋㅋㅋ 이제보니까 입력파일에 9가 두개 있었네 컴파일 됨 ㅇㅇ
지금까지 코드에 문제가 있나 해서 계속 봤는데 허무하네