From 76a0fcd008ddcdb5695ac24f6d73c5c5725b1fe2 Mon Sep 17 00:00:00 2001 From: 18783852161 <18783852161@163.com> Date: Tue, 8 Jan 2019 16:42:26 +0800 Subject: [PATCH] second commit --- 1.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 1.c diff --git a/1.c b/1.c new file mode 100644 index 0000000..4592a32 --- /dev/null +++ b/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); +}