求助各位大佬:
#include <stdio.h>#include <stdlib.h>
struct student
{
int num;
char name[10];
float score[3];
};
int main()
{
void input(struct student stu[5]);
void print(struct student *s);
struct student stu[5];
struct student *p;
p=stu;
printf("input data:\n");
input(stu);
printf("output data:\n");
print(p);
return 0;
}
void input(struct student stu[5])
{
int i;
for(i=0;i<5;i++)
{
scanf("%d%s%f%f%f\n",&stu[i].num,stu[i].name,&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);
}
}
void print(struct student *s)
{
int i;
for(i=0;i<5;i++,s++)
{
printf("%-5d %-10s %.2f %.2f %.2f\n",s->num,s->name,s->score[0],s->score[1],s->score[2]);
}
}
为什么调用了print函数,不能输出呢?只能执行输入