请大家看看我这个程序错在那里
#include "stdio.h"#define SIZE 5
struct student
{char name[10];
int num;
int score[3];
float ave;
} stu[SIZE];
void main()
{void save(void);
int i;
float sum[SIZE];
FILE *fp1;
for(i=0;i<SIZE;i++)
{scanf("%s %d %d %d %d",stud[i].name,&stud[i].num,&stud[i].score[0],这行运行
老出错stud这个有错 &stud[i].score[1],&stud[i].score[2]);
sum[i]=stud[i].score[0],+stud[i].score[1]+stud[i].score[2]+stud[2];
stud[i].ave=sum[i]/3;
}
save();
fp1=fopen("stu.dat","rb");
printf("\n name No score1 score2 score3 ave\n");
printf("----------------------------------------\n");
for(i=0;i<SIZE;i++)
{fread(&stud[i],sizeof(struct student),1,fp1);
printf("%-10s %3d %7d %7d %7d %8.2f\n",stud[i].name,stud[i].name,
stud[i].score[0],stud[i].score[1],stud[i].score[2],stud[i].ave);
}
fclose (fp1);
}
void save(void)
{FILE *fp;
int i;
if((fp=fopen("stu.dat","wb"))==NULL)
{printf("The file can not open\n");
return;
}
for(i=0;i<SIZE;i++)
if(fwrite(&stu[i],sizeof(struct student),1,fp)!=1)
{printf("file write error\n");
return;
}
fclose(fp);
}
请大家给我指出来
在这我谢谢大家了哦