You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
766 B

void enter()
{
int i,m=0;
char n;
char to[20],ch[2];
printf("请输入单词: ");
scanf("%s",to);
FILE *fp;
if((fp=fopen("data.txt","ab+"))==NULL)
{
printf("文件不存在!\n");
exit(1);
}
while(!feof(fp))
{
if(fread(&inf[m],LEN,1,fp)==1)
{
if(strcmp(to,inf[m].word)==0)
{
printf("释义: ");
printf("%s\n",inf[m].mean);
printf("是否继续?");
printf("按Y或y表示继续,按其它键返回\n");
scanf("%c",&n);
fclose(fp);
return;
}
}
m++;
}
printf("无此单词!\n");
printf("是否继续?");
printf("按Y或y表示继续,按其它键返回\n");
scanf("%c",&n);
fclose(fp);
return;
if(m==0)
printf("文件中无记录!\n");
if((fp=fopen("data.txt","ab+"))==NULL)
{
printf("文件不存在!\n");
return;
}
fclose(fp);
}