C语言编译时出现Expression:(stream!=NULL)
#include<stdio.h>structstud{charstuNAME[20];doublescore1;doublescore2;doublezongfen;}...
#include <stdio.h>struct stud{ char stuNAME[20]; double score1; double score2; double zongfen;}a[100],d;void main(){ int i,j=0,m,x; char p[10],q[10],w[10]; FILE *fp; FILE *fin; fp=fopen("stu.txt","r"); fin=fopen("total.txt","w"); fscanf(fp,"%s%s%s",p,q,w); while(fscanf(fp,"%s%d%d",a[j].stuNAME,a[j].score1,a[j].score2)!=NULL) { fscanf(fp,"%s%d%d",a[j].stuNAME,a[j].score1,a[j].score2); a[j].zongfen=a[j].score1+a[j].score2; j++; } for(m=0;m<j;m++) { for(x=0;x<j;i++) { if(a[x+1].zongfen>a[x].zongfen) { d=a[x+1]; a[x+1]=a[x]; a[x]=d; } } } fprintf(fin,"%s","Name Total"); for(i=0;i<j;i++) { fprintf(fin,"%s %d",a[i].stuNAME,a[i].zongfen); fprintf(fin,"\n"); } fclose(fp); fclose(fin);}
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询