Problem with if statement
I am running an if-else statement to output an error when a word can't be found in a dictionary file. The program reads word 1 from the user text file and then loops through a dictionary file to find the word. The problem is that for every word in the dictionary that doesn't match, it outputs the error. How do I make it output the error after it has scanned the whole dictionary??
Code:
while(fscanf(fp2,"%s", wordcheck)!=EOF)//Reads word from text file into array// {
for (i=0; wordcheck[i]; i++)
{
wordcheck[i] = tolower(wordcheck[i]);//makes all characters lower case//
}
fseek(fp1,0,SEEK_SET);
printf("%s", wordcheck);//debugger
while(fscanf(fp1,"%s", worddict))
{
if(strcmp(wordcheck, worddict)==0)//compare strings//
{
printf("This word: %s is in the dictionary\n", wordcheck);//debugger//
break;
}
else
{
printf("This word %s is not in the dictionary", wordcheck);
}
}
}