为什么无法输出"成绩最好的是"后面的字符串
#include<stdio.h>#define N 4
struct date
{
int math;
int english;
int chinese;
};
struct student
{
char *name;
int number;
int age;
struct date score;
float ave;
};
void max(struct student stu[]);
void main()
{
int i,j;
struct student CLASS[N],* p=CLASS;
for(i=0;i<N;i++,p++)
{
printf("请输入第%d个人的信息\n",i+1);
printf("请输入姓名:");
scanf("%s",p->name);
printf("请输入学号:");
scanf("%d",&p->number);
printf("请输入年龄:");
scanf("%d",&p->age);
printf("请输入数学、英语、语文成绩:");
scanf("%d%d%d",&p->score.math,&p->score.english,&p->score.chinese);
p->ave=(p->score.math+p->score.english+p->score.chinese)/3.0;
}
printf("**************************学生信息**************************\n姓名\t学号\t年龄\t数学\t英语\t语文\t平均成绩\n");
for(j=0,p=CLASS;j<N;j++,p++)
{
printf("%s\t%d\t%d\t%d\t%d\t%d\t%6.2f\n",p->name,p->number,p->age,p->score.math,p->score.english,p->score.chinese,p->ave);
}
max(p);
}
void max(struct student stu[])
{
int i,j=0;
for(i=0;i<N;i++)
{
if(stu[i].ave>stu[j].ave)
j=i;
}
printf("成绩最好的是 %s\n",stu[j].name);
}