这是程序 大家帮忙看看 楼上的方法都不行呀
#include "stdio.h"struct Node //定义一个节点结构体类型 { long num; char name[10]; float math; float chinese; float english; }stu[10]={这里是些随便编的数据};void main()
{ FILE *fp,*fbj,*fj; struct Node *q;int n;struct Node st[10],bj[10],jg[10]; fp=fopen("score.txt","w+"); q=&stu[0]; for (n=0;n<10;n++) { fwrite(&stu[n],sizeof (struct Node),1,fp)!=1) ; }/*把成绩输入到score.txt里面去*/ fclose(fp); fp=fopen("score.txt","r+"); fbj=fopen("bjg.txt","r+"); fj=fopen("jg.txt","r+"); for (n=0;n<10;n++) { fread(&st[n],sizeof (struct Node),1,fp); if (st[n].chinese<60||st[n].math<60||st[n].english<60) { fbj=fopen("bjg.txt","a"); fwrite(&stu[n],sizeof (struct Node),1,fbj); fclose(fbj); } else { fj=fopen("jg.txt","a"); fwrite(&stu[n],sizeof (struct Node),1,fj); fclose(fj); }; }/* 打开score.txt,并将不及格成绩输出到bjg.txt,再把及格成绩输出到jg.txt*/ fclose(fp); printf("学号 姓名 语文 数学 英语\n"); fbj=fopen("bjg.txt","r"); for (n=0;;n++)/* 问题就在这 限制条件不知道用啥 楼上的方法都试过 没有用 大家帮忙看看是不是前面那错了 */ { fread(&jg[n],sizeof (struct Node),1,fj); printf("%d %-5s %5.0f %5.0f %5.0f\n", bj[n].num,bj[n].name,bj[n].chinese,bj[n].math, bj[n].english); } fclose(fbj); fj=fopen("jg.txt","r"); printf("学号 姓名 语文 数学 英语\n"); for (n=0;;n++) { fread(&jg[n],sizeof (struct Node),1,fj) printf("%d %-5s %5.0f %5.0f %5.0f\n", jg[n].num,jg[n].name,jg[n].chinese,jg[n].math, jg[n].english); } fclose(fj);}