如果我取一个包含单词列表的文本文件并希望将此列表与多个列表(已经提供给程序)进行比较,则表示输入列表中的任何单词是否与任何单词匹配源列表中我希望只有在list1.txt中找到该单词时才将该单词存储在文件a.txt中。类似地,如果在list2.txt中找到该单词,我希望它存储在b.txt中。与此同时,我想在输出文件a.txt中显示文件list1.txt的路径。 喜欢 唱./dataset/dictionary/verb
我使用了以下语法
while(dictcount >= 0)//reads dictionary word into array//
{
dictcount = 0; //searches through all of the listed data files
fscanf(fp1,"%s", worddict);
fscanf(fp2,"%s", worddict);
fscanf(fp3,"%s", worddict);
if(strcmp(wordcheck, worddict)==0)//compare strings//if the word in found in list misc.txt
{
fprintf(out_file1 ,"%c", wordcheck); //storing the value in output_misc.txt
if (getcwd(cwd, sizeof(cwd)) != NULL)
//fprintf(out_file3, "%c\n", cwd); //stores the path of the folder containing the list in which the matched 'word' is found
return 0;
}
}
答案 0 :(得分:0)
为什么不使用“EOF”来读取文件? 有一个类似你的问题。 http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/459823f5-e5a7-46a4-9192-d607be0747f3/