From 2d88d3c9fe94a7831f0310621cbada887f89b624 Mon Sep 17 00:00:00 2001 From: m59637281 <18408000220@stu.hut.edu.cn> Date: Fri, 4 Jan 2019 11:07:33 +0800 Subject: [PATCH] Third --- get_info.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 get_info.c diff --git a/get_info.c b/get_info.c new file mode 100644 index 0000000..eb39893 --- /dev/null +++ b/get_info.c @@ -0,0 +1,36 @@ +#include + +int main(void) +{ + struct custom + { + char name[20]; + char ID[20]; + char card_number[20]; + float sum; + }a; +FILE *fp; +char c='Y'; +fp=fopen("sum.dat","w");//创建只写文件 +while(c=='Y'||c=='y')//判断循环 +{ + printf("输入姓名:"); + scanf("%s",a.name); + getchar(); + printf("输入身份证号:"); + scanf("%s",a.ID); + printf("输入卡号:"); + scanf("%s",a.card_number); + printf("输入余额:"); + scanf("%f",&a.sum); +fprintf(fp,"%s%s%s%.2f\n",a.name,a.ID,a.card_number,a.sum); + while(1) + { + printf("继续录入?"); + c=getche(); + if(c=='Y'||c=='y'||c=='N'||c=='n') + break; + } +} +fclose(fp); +}