c语言结构体函数调用参数怎么设置
函数结构是下面的代码,main函数中如何调用showinfo函数,参数应该怎么设置,对参数的设置不太明白
#include <stdio.h>#define SIZE 5#define LEN 40struct birth{int year;int month;};struct student{int num;char name[LEN];int age;char sex[LEN];struct birth stu;};struct student getinfo(struct student *,int);struct student showinfo(struct student);int main(void){int n=0;int i;struct student st[SIZE];struct student *pst=st;while(n<SIZE){st[n]=getinfo(st,n);n++;}for(n=0;n<SIZE;n++){showinfo(pst,n);}return 0;}struct student getinfo(struct student *temp,int n){int i;printf("NO is %d\n",n+1);temp[n].num=n+1;printf("please input the name:\n");scanf("%s",temp[n].name);printf("please input the age:\n");scanf("%d",&temp[n].age);printf("please enter sex(0 is boy, 1 is girl)");scanf("%d",&i);strcpy(temp[n].sex,(i==0)?"boy":"girl");printf("please input the birth:\n");scanf("%d%d",&temp[n].stu.year,&temp[n].stu.month);}struct student showinfo(struct student *pst,int n){printf("%d %s %d %s %d-%d \n",(pst+n)->num,(pst+n)->name,(pst+n)->age,(pst+n)->sex,(pst+n)->stu.year,(pst+n)->stu.month);}#include <stdio.h>#define SIZE 2#define LEN 40struct birth{ int year; int month;};struct student{ int num; char name[LEN]; int age; char sex[LEN]; struct birth stu;};void getinfo(struct student *,int);//void showinfo(struct student *);//int main(void){ int n=0; int i; struct student st[SIZE]; struct student *pst=st; while(n<SIZE) { //st[n]=getinfo(st,n); getinfo(st,n); n++; } for(n=0;n<SIZE;n++) { showinfo(pst,n); } return 0;}void getinfo(struct student *temp,int n)//{ int i; printf("NO is %d\n",n+1); temp[n].num=n+1; printf("please input the name:\n"); scanf("%s",temp[n].name); printf("please input the age:\n"); scanf("%d",&temp[n].age); printf("please enter sex(0 is boy, 1 is girl)"); scanf("%d",&i); strcpy(temp[n].sex,(i==0)?"boy":"girl"); printf("please input the birth:\n"); scanf("%d%d",&temp[n].stu.year,&temp[n].stu.month);}void showinfo(struct student *pst,int n)//{ printf("%d %s %d %s %d-%d \n",(pst+n)->num,(pst+n)->name,(pst+n)->age,(pst+n)->sex,(pst+n)->stu.year,(pst+n)->stu.month);}