#include <stdio.h>
#define CSIZE 4
#define SCORE 3
void getgrade(struct student*p);
struct name{
char firstname[20];
char lastname[20];
};
struct student{
struct name names;
float grade[SCORE];
float aver;
};
int main()
{
struct student students[CSIZE]={{"Xiao","Ming"},{"Xiao","Mei"},{"Xiao","Wang"},{"Xiao","Li"}};
getgrade(students);
return 0;
}
void getgrade(struct student*p)
{
int i,j;
for(i=0;i<CSIZE;i++)
{
printf("input %d socres of %s %s",SCORE,p[i].names.firstname,p[i].names.lastname);
for(j=0;j<SCORE;j++)
scanf("%f",&p[i].grade[j]);
}
}
函数使用已经提前声明了 调用和声明形式也一样 为什么出错
为了方便提问省略了一些无关的代码