The task that i'm trying to perform is to count the number of times that an specific word is repeated on a .txt file. In this case the word "the".
My first attempt is:
Code:
while(*bufptr++ != '\0'){
if(strncmp (bufptr,"the",3) == 0){
i++;
}}
printf("The word THE was writen %d times on the file\n",i);
where bufptr is a pointer to memory: char *bufptr;
The problem is that with that code it counts not only "the" but also words such as "theater", "lathe". How can i narrow the counting to only count "the" words?.
Thanks in advance.