second commit

master
18783852161 6 years ago
parent 8924c9ba51
commit 76a0fcd008

31
1.c

@ -0,0 +1,31 @@
void add()
{
int i,m=0;
char n;
char ch[2];
FILE *fp;
if((fp=fopen("data.txt","ab+"))==NULL)
{
printf("文件不存在!\n");
exit(0);
}
fseek(fp,0L,2);
printf("请输入单词: \n");
scanf("%s",inf[m].word);
printf("请输入释义:\n");
scanf("%s",inf[m].mean);
if(fwrite(&inf[m],LEN,1,fp)!=1)
{
printf("不能保存");
getchar();
}
else
{
printf("已保存\n是否继续添加?");
scanf("%c",&n);
if(n=='Y'||n=='y')
add();
m++;
}
fclose(fp);
}
Loading…
Cancel
Save