#include <stdio.h>
#include <stdlib.h>
struct Student
{
int sid;
int age;
};
struct Student *CreatStudent(void);
void ShowStudent(struct Student *);
int main(void)
{
struct Student * ps;
ps = CreatStudent();
ShowStudent(ps);
return 0;
}
void ShowStudent(struct Student * pst)
{
printf("%d %d",pst->sid,pst->age);
}
struct Student *CreatStudent(void)
{
struct Student * p = (struct Student*)malloc(sizeof(struct Student));
p->sid = 99;
p->age = 88;
return p;
}
程序运行示例:
-----------------------------
99 88
-----------------------------