hello ..
i have a question
i have file of words ( dictionary) and i have another file(list) with list of words that could be or could not be in (dictionary)
so i need to read from (List) and check if it exist in (Dictionary)
and i want to check if the word exist or not .. help me out please , i couldn't figure it out
Code:
#define LENGTH
int main(void)
{
FILE *Dict_f;
FILE *Word_f;
int w, index, s;
char word[LENGTH];
// open the dictionary file
Dict_f = fopen("Dictionary.txt", "r");
// check if the file opened
if (Dict_f == NULL) {
printf("Couldn't Open File: Dictionary.txt!\n");
exit(-1);
}
// open the test text file
Word_f = fopen("list.txt", "r");
// check if the file opened
if (Word_f == NULL) {
printf("Couldn't Open File: list.txt!\n");
exit(-1);
}
//extracting the word
do {
w = fscanf(Word_f, "%s", word);
s = strlen(word);
CheckExist(word) // function to check if the word exist in Dict_f or not
} while (w != EOF); /* repeat until EOF */
fclose(Word_f);
fclose(Dict_f);
return 0;
}
i know i should use sth like strcmp but what other condition with it ?
if (strcmp(word, ...)==0)
thank you !