how do i count the same word ?
Posted on 1998-11-02
i already write a program that count how many word in that sentence
char string ;
printf("please enter your note:\n");
token=strtok (string," ");
while (token != NULL)
token=strtok (NULL," ");
for example the output
please enter your note:
i go to school i still go to school tomorrow
on the output i just can count that the sentence got 10 words but my question is how do i count the "go" is 2 and the "to" is 2 when user just want to count how many "go" and "to" in the sentence
i thinks to use the strcmp to compare each word but the "go" and "to" are the same (2 characters) so will return 0 and can't count the different word "go" and "to".
thanks for helping me