How to count specific words in a text file
i am unable to get the specific words. my code: ``` #include <stdio.h> #include <string.h> int main() { FILE *fp; char filename[100]; char ch; int linecount; linecount = 0; printf("Enter a filename :"); gets(filename); fp = fopen(filename,"r"); int match( char *word ) { char *targets[] = {"auto", "the", ""}; char **t = targets; while ( *t[0] != '\0' && strcmp(*t, word)) t++; return *t[0] != '\0'; } if ( fp ) { while ((ch=getc(fp)) != EOF) { if (ch == '\n') { ++linecount; } } if (linecount > 0) { ++linecount; } } else { printf("failed to open the file\n"); } printf("Lines : %d \n", linecount); return(0); } ``` the task is to count the number of lines and specific words present in a text file. i was unable to count the specific words present in the text file. could anyone help me with it. Thanks in advance.