Here is an extract for some code that I am working on. Just wondering how would I go about resetting the nested loop? It remains at the end of the file when the first loop runs again.
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//
}
printf("%s", wordcheck);
while(fscanf(fp1,"%s", worddict))
{
if(strcmp(wordcheck, worddict)==0)//compare strings//
{
printf("This word: %s is in the dictionary\n", wordcheck);
dictcount++;
break;
}
else
{
dictcount++;
}
if(worddict == NULL)
{
printf("Your word: %s is not in the dictionary\n", wordcheck);
}
}
}
Use
fseek:.. or more simply,
rewind: