1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| #include<stdio.h> #include<malloc.h> struct Student { int sid; char name[100]; int age; }; struct Student * CreateStudent(void); void ShowStudent(struct Student *pst); int main(void) { struct Student *ps; ps = CreateStudent(); ShowStudent(ps); return 0; } struct Student * CreateStudent(void) { struct Student *p = (struct Student *)malloc(sizeof(struct Student)); p->sid = 99; p->age = 88; return p; } void ShowStudent(struct Student *pst) { printf("%d %d\n",pst->sid, pst->age); }
|