My program find the amount of specific word such as "whale" and "thee", but ignore "thee,", "whale....", and so on. How can I contain them?
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main(){
FILE *md,*out;
char CHA[255];
char cha[255];
cha[255]=tolower(CHA[255]);
char thee[]="thee";
char chapter[]="chapter";
char whale[]="whale";
char meet[]="meet";
int th=0;
int ch=0;
int wh=0;
int me=0;
md=fopen("moby_dick.txt","r");
out=fopen("output.txt","w");
if(md==NULL){
printf("Empty text");
return 1;
}
while(feof(md)==0){
fscanf (md,"%s",&cha);
if(strcmp(cha,thee)==0 ){
th++;
}
if(strcmp(cha,chapter)==0){
ch++;
}
if(strcmp(cha,whale)==0){
wh++;
}
if(strcmp(cha,meet)==0){
me++;
}
}
printf("%d\n",th);
printf("%d\n",ch);
printf("%d\n",wh);
printf("%d\n",me);
fprintf(out,"%d\n",th);
fprintf(out,"%d\n",ch);
fprintf(out,"%d\n",wh);
fprintf(out,"%d\n",me);
fclose(md);
fclose(out);
}