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); +}