哪错啦(关于结构体)
#include "stdio.h"#include<string.h>
struct student
{
char num[6];
char name[8];
double score[3];
float avr;
} stu[2],s;
main()
{
int i,j;
float sum=0;
FILE *fp;
/*input*/
for(i=0;i<2;i++)
{
printf("\n please input No. %d score:\n",i+1);
printf("stuNo:");
scanf("%s",stu[i].num);
printf("name:");
scanf("%s",stu[i].name);
for(j=0;j<3;j++)
{
printf("score %d.",j+1);
scanf("%lf",&stu[i].score[j]);
}
printf("\n");
}
for(i=0;i<3;i++)
for(j=0;j<2;j++)
{
sum+=stu[i].score[j];
}
s.avr=sum/3.0;
printf("%f",s.avr);
fp=fopen("c:\\stud","w");
for(i=0;i<2;i++)
if(fwrite(&stu[i],sizeof(struct student),1,fp)!=1)
printf("file write error\n");
fclose(fp);
getch();
}