源程序:
#include <stdio.h>
#include <malloc.h>
struct Student //结构体
{
int sid; //学号
int age; //年龄
};
struct Student *CreateStudent()
{
struct Student *stu=(struct Student *)malloc(sizeof(struct Student));//malloc()分配空间
stu->age=22;
stu->sid=1001;
return stu;
}
void ShowStudentInfo(struct Student *stu)
{
printf("sid=%d,age=%d\n",stu->sid,stu->age);
}
int main()
{
struct Student *xiaoMing=CreateStudent();
ShowStudentInfo(xiaoMing);
return 1;
}