strtok사용
내길
질문 제목 : strtok사용해서 단어의 빈도수 구하기질문 요약 :else부분 설명질문 내용 : #include stdio.h
#include string.h
int main(void)
{
char line[10][100];
int i = 0, j = 0,a=0;
int count = 0;
char *delimiter = ;
char *ptoken;
char *word[100];
int wordcnt[100] = {0};
printf(몇번 입력\n);
scanf(%d,&a);
while (i=a)
{
gets(line[i]);
line[i++];
}
printf(\n);
for(i = 0; i = a; i++) {
ptoken = strtok(line[i], delimiter);
while( ptoken != null ) //여기부터
{
if (count == 0)
{
word[count] = ptoken;
wordcnt[count++]++;
}
else
{
for (j = 0; j count; j++)
{if (strcmp(ptoken, word[j]) == 0)
{
wordcnt[j]++;
break;
}
}
if (j == count) {
word[count] = ptoken;
wordcnt[count++]++;
}
}//여기까지
ptoken = strtok(null, delimiter);
}
}
for (i = 0; i count; i++)
printf(%10s : %d \n, word[i], wordcnt[i]);
return 0;
}
//로 주석처리 해놓은 부분이 이해가 가질 안네요...ㅠㅠ