跨函数使用内存

#include <stdio.h>
#include <stdlib.h>

struct Student {
    int sid;
    int age;
};

struct Student * CreatStudent(void) {
    struct Student * pst = (struct Student *)malloc(sizeof(struct Student));
    pst->sid = 100;
    pst->age = 99;
    return pst;
}

void ShowStudent(struct Student * pst) {
    printf("打印: %d, %d", (*pst).sid, (*pst).age);
}

int main(void) {

    struct Student * st;
    st = CreatStudent();
    ShowStudent(st);

    return 0;
}
原文地址:https://www.cnblogs.com/jiefangzhe/p/10154231.html