错在哪#include "stdio.h" #define N 5 struct student { long num; char name[10]; int age; float score[7]; float total; } stu[N]; main() { int i,j,max,k; FILE *fp; for(i=0;i<N;i++) {printf("please input number!"); scanf("%ld",&stu[i].num); printf("please input name"); scanf("%s",stu[i].name); printf("please input age"); scanf("%d",&stu[i].age); for(j=0;j<7;j++) { printf("please input score!"); }scanf("%f",&stu[i].score[j]); stu[i].total=0.0; for(j=0;j<7;j++); stu[i].total+=stu[i].score[j]; }
if((fp=fopen("c:\\student.dat","wb+"))==NULL) {printf("file can not open!"); getch(); exit(0); } fwrite(stu,sizeof(struct student),N,fp); fread(stu,sizeof(struct student),N ,fp); max=stu[0].total; k=0; for(i=0;i<N;i++) if(max<stu[i].total) {max=stu[i].total;k=i;}
printf("%-6ld%-10s%-5d%6.2f\n",stu[k].num,stu[k].name,stu[k].age,stu[k].total); getch(); }里?输入里面的问题!但为何错了呢?