comparing a string from a file in C

guys could anyone help me how to compare a strinf from a file.
example i entered the word "plus" then the program should search
it from a file then print if it is true or not.. please help me :D

this is my code:

wlist.txt contains words to be compared by get

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include<stdio.h>
main()
{
FILE *fp;
char get,store;
fp=fopen("i:\\wlist.txt","r");
printf("Enter word to find: ");
scanf("%s",&get);
strcpy(&get);
while(fp!=EOF){
fscanf(fp,"%s\n",store);
if(strcmp(store,get)==1)
{
printf("Found! %s",store);
getch();
}
else
printf("Not Found!");
getch();
}
}


please help me to correct any mistakes in this code.. i don't know why it doesn't work.. i hope anyone could help me..


please help me to correct this error..
Last edited on
strcmp returns 0 when strings are equal.
if(strcmp(store,get)==0) // should work fine now

And when posting code, please use [code][/code] tags to make code more readable
Topic archived. No new replies allowed.