#include<stdio.h>
#include<stdlib.h>
struct Student
{
int sid;
int age;
};
struct Student * CreateStudent()
{
struct Student * p = (struct Student *) malloc(sizeof(struct Student));
return p;
}
void ShowStudent(struct Student *ps)
{
printf("%d,%d\n", ps->sid, ps->age);
}
int main()
{
struct Student * ps;
ps = CreateStudent();
ps->age = 1;
ps->sid = 2;
ShowStudent(ps);
free(ps);
}
malloc函数使用
最新推荐文章于 2023-12-12 22:53:07 发布