求助,关于结构体
想编写input(),output()两个函数,涉及到结构体,系统编译通不过,不知道该怎么改,请大家帮看看
程序代码:#include<stdio.h>
struct Student
{
int num;
char name[10]; /*定义数据结构并定义该结构的有3个元素的数组*/
int score[3];
};struct Student stu[3];
main()
{ struct Student *p; /*定义一个结构体的指针*/
(struct Student*) input();/*声明一个返回结构体指针的无参input函数*/
output(struct Student*);/*声明一个以结构体指针为参数的无返回output函数*/
p=input(); /*指针p接收input返回值*/
output(p); /*指针p作为函数output的参数*/
return 0;
}
input()
{
int i,j;
for(i=0;i<3;i++)
{ printf("input the %d of 3",i+1);
printf("\nnum:");
scanf("%d",&stu[i].num);
printf("\nname:");
scanf("%s",stu[i].name);
for(j=0;j<3;j++)
{
printf("\nscore%d:",j+1);
scanf("%d",&stu[i].score[j]);
} /*此处循环输入结构体数组的内容*/
}
return(stu);/*返回结构体指针*/
}
output(stu)
{
int i,j;
printf("num name score1 score2 score3");
for(i=0;i<3;i++)
{
printf("%d%s",stu[i].num,stu[i].name);
for(j=0;j<3;j++)
{ /*输出*/
printf("%d",stu[i].score[j]);
printf(""\n);
}
}
}第11行output(struct Student*);/*声明一个以结构体指针为参数的无返回output函数*/处一直报错,实在不知道怎么改好了。。
帮我看看,拜谢。。。。










困惑
求指点啊