second commit

master
13574675339 6 years ago
parent 1f884bb80a
commit c19677cdcd

@ -0,0 +1,45 @@
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);
}
Loading…
Cancel
Save