5000单词查询(文件)

#include
#include
#include
typedef struct English
{
char word[30];
char paraphrase[100];
}ENG;
int main()
{
ENG search[5000];
char fname[30],word[30];
int i;
FILE*fin;
printf(“please Input the file’s name to read:”);
gets(fname);
if((fin=fopen(fname,“r”))==NULL)
{
printf(“Failure to open %s\n”,fname);
exit(0);
}
for(i=0;i<5000;i++)
{
fscanf(fin,"%s",search[i].word);
fgetc(fin);
fgets(search[i].paraphrase,105,fin);
search[i].paraphrase[strlen(search[i].paraphrase)-1]=’\0’;
}
fclose(fin);
printf(“please input the word to inquire:\n”);
scanf("%s",word);
for(i=0;i<5000;i++)
{
if(strcmp(search[i].word,word)0)
{
puts(search[i].paraphrase);break;
}
putchar(’\n’);
}
if(i
5000)
printf(“Not found\n”);
return 0;
}

你可能感兴趣的:(文件)