小菜鸟遇到大问题了,大佬帮我 编译器一直报错,在AverScore函数中 65 8 H:\C语言练习\例13.5.c [Warning] assignmen
#include<stdio.h>#include<stdlib.h>
#define N 30
typedef struct data
{
int year;
int month;
int day;
}DATA;
typedef struct student
{
long studentID;
char studentName[10];
char studentSex;
DATA birthday;
int score[4];
float aver;
}STUDENT;
void InputScore(STUDENT stu[],int n,int m);
void AverScore(STUDENT stu[],int n,int m);
void WritetoFile(STUDENT stu[],int n,int m);
int main()
{
STUDENT stu[N];
int n;
printf("How many student?");
scanf("%d",&n);
InputScore(stu,n,4);
AverScore(stu,n,4);
WritreScore(stu,n,4);
return 0;
}
void InputScore(STUDENT stu[],int n,int m)
{
int i, j;
for(i=0;i<n;i++)
{
printf("Input record %d:\n",i+1);
scanf("%ld",&stu[i].studentID);
scanf("%s",stu[i].studentName);
scanf(" %c",&stu[i].studentSex);
scanf("%d",&stu[i].birthday.year);
scanf("%d",&stu[i].birthday.month);
scanf("%d",&stu[i].birthday.day);
for(j=0;j<m;j++)
{
scanf("%d",&stu[i].score[j]);
}
}
}
void AverScore(STUDENT stu[],int n,int m)
{
int i,j,sum;
for(i=0;i<n;i++)
{
sum=0;
for(j=0;j<m;j++)
{
sum=sum+stu[i].score;
}
stu[i].aver=(float)sum/m;
}
}
void WritetoFile(STUDENT stu[],int n,int m)
{
FILE *fp;
int i,j;
if((fp=fopen("score.txt","w"))==NULL)
{
printf("Failure to open score.txt!\n");
exit(0);
}
fprintf(fp,"%d\t%d\n",n,m);
for(i=0;i<n;i++)
{
fprintf(fp,"%10ld%8s%3c%6d%02d%02d",stu[i].studentID,stu[i].studentName,stu[i].studentSex,stu[i].birthday.year,stu[i].birthday.month,stu[i].birthday.day);
for(j=0;j<m;j++)
{
fprint(fp,"%4d",stu[i].score[j]);
}
fprintf(fp,"%6.lf\n",stu[i].aver);
}
fclose(fp);
}