Im writing a dictionary program in C thus far my program opens a txt file(dictionary) and then opens another txt file to be checked for spelling it compares every word in the document with every word in the dictionary file at this point it prints out the first word that is spelled wrong in the document but, never goes back into the inner while loop im not shure how to fix this problem
here is the last part of my code Please HELP!
//compare document to dictionary
char dictword[300];
char misword[300];
FILE *fp1, *fp2;
fp2 = fopen("dictionary.txt","r"); //open dictionary
fp1 = fopen("mispelled.txt","r"); //open document to be checked for spelling
while (test != EOF)//run loop until every misword file has been checked
{
test = fscanf(fp1,"%s",misword); //gets one word from the dictionary file
while (test2 != EOF)//run loop until every word in dict file has been checked
{
test2 = fscanf(fp2,"%s",dictword); //gets one word from the dictionary file
if (0==strcmp(misword,dictword))//if misword is = to dictword
break; //if a word in the misword file matches the dictionary word it must be spelled correct, break out of loop
else if(test2 == EOF)//if one misword is compared with every dictword misword must not be a word
printf("%s This word is not found in the dictionary \n",misword); //thus print it
}
} //while (test != EOF);//run loop until every misword file has been checked
fclose(fp2);
fclose(fp1);