为了账号安全,请及时绑定邮箱和手机立即绑定

请问为什么我修改缴费文件的信息只能修改第一条?具体代码如下,求大神解答!谢谢!!!!

请问为什么我修改缴费文件的信息只能修改第一条?具体代码如下,求大神解答!谢谢!!!!

C
冷眼笑看人间物是人非 2017-01-01 21:37:40
void jiaofei(){ FILE *f;  if((f=fopen("E://jiaofei.txt","a"))!=NULL)  {  int i;  system("cls");  printf("您一共要缴的费用为5000元!\n");  printf("请输入您的学号:\n");  scanf("%s",yonghu[0].num);  printf("请输入您的姓名:\n");  scanf("%s",yonghu[0].name);  system("cls");  printf("请输入您要缴费的金额:\n");  scanf("%d",&yonghu[0].x);  yonghu[0].y=5000-yonghu[0].x;  if(yonghu[0].x>5000) {printf("您所输入的金额大于您所应当缴费的金额,请重新输入缴费金额!\n");}  else   printf("缴费成功!\n");  printf("您还应当缴的费用为%d",yonghu[0].y);  fprintf(f,"%s ",yonghu[0].num);  fprintf(f,"%s ",yonghu[0].name);  fprintf(f,"%d ",yonghu[0].x);  fprintf(f,"%d\n",yonghu[0].y);  fclose(f);  system("pause");  return;  }}void bujiao(){ int i,n; int m=0; char num[20]; FILE *f; printf("请输入补缴学费学生的学号:\n"); scanf("%s",num); f=fopen("E://jiaofei.txt","r"); for(i=0; !feof(f) && i<=10000; i++) { if(fscanf(f,"%s",yonghu[i].num)!=1)  break; if(fscanf(f,"%s",yonghu[i].name)!=1) break; if(fscanf(f,"%d",&yonghu[i].x)!=1)   break; if(fscanf(f,"%d",&yonghu[i].y)!=1)   break; if(strcmp(num,yonghu[i].num)==0) { m=1; printf("学号:%s ",yonghu[i].num); printf("姓名:%s ",yonghu[i].name); printf("已缴学费:%d ",yonghu[i].x); printf("未缴学费:%d\n",yonghu[i].y); } } if(m==0) printf("查无此人!"); //scanf("%*s"); //fclose(f); if((f=fopen("E://jiaofei.txt","r+"))!=NULL) { printf("请输入您要补缴学费的金额:\n"); scanf("%d",&yonghu[0].x1);    if(yonghu[0].x1>yonghu[0].y)    {printf("您所输入的金额大于您所应当缴费的金额,请重新输入缴费金额!\n");}  else     printf("补缴成功!\n");    printf("您还应当缴的费用为%d",5000-yonghu[0].x-yonghu[0].x1);     fprintf(f,"%s ",yonghu[0].num);     fprintf(f,"%s ",yonghu[0].name);     fprintf(f,"%d ",yonghu[0].x+yonghu[0].x1);     fprintf(f,"%d\n",5000-yonghu[0].x-yonghu[0].x1);     fclose(f); } }
查看完整描述

1 回答

?
DOUBLE_l

TA贡献45条经验 获得超12个赞

你是声明了结构体类型吗?方便的话把源代码贴出来!
查看完整回答
反对 回复 2017-01-02
  • 1 回答
  • 0 关注
  • 1049 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信