以下是我正在處理的一些代碼的摘錄。只是想知道我將如何去重置嵌套循環?當第一個循環再次運行時,它仍然保留在文件末尾。如何重置while循環?
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);
}
}
}
呃,'while'語句末尾的';'是pastebin的拼寫錯誤,對不對? – fge 2011-12-20 14:16:37
關閉並重新打開文件? – user973572 2011-12-20 14:17:02
哎呀哈哈是的;是一個錯字:D – adohertyd 2011-12-20 14:18:51