I am a new learner of C and I tried to write a program about searching a keywrod from a .txt file and counting the number of time that the keyword repeats
My program is below...it can't work...and I can't understand why....
can someone please help me...T_T
Thank you
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
FILE *fptr;
fptr=fopen("composition.txt","r");
int cnt_keyword=0;
char word[80];
char keyword[80];
printf("Enter the word you want to search for:");
scanf("%s",&keyword);
while (fscanf(fptr, "%80s", word) != EOF)
{
if (strcasecmp(word, keyword) == 0)
{
++cnt_keyword;
}
}
printf("No. of keyword: %d",cnt_keyword);
system("pause");
}