zoukankan      html  css  js  c++  java
  • 跨函数使用内存案例

     1 #include<stdio.h>
     2 #include<malloc.h>
     3 struct student{
     4      int age;  
     5 };
     6 struct studnet * createStudent();//函数声明,创建学生年龄
     7 void showstudent(struct studnet *);//函数声明,输出学生年龄
     8 int main(){
     9     strunct student * ps;
    10     ps = createStudent();
    11     showstudent(ps);
    12     return 0;
    13 }
    14 struct studnet * createStudent(){
    15     struct studnet * p = (struct student *)malloc(sizeof(struct student));
    16     p->age=19;
    17     return p;
    18 }
    19 void showstudent(struct studnet *pst){
    20     printf("%d",pst->age);
    21 }
  • 相关阅读:
    HDU
    POJ
    POJ
    POJ
    POJ
    POJ
    POJ
    SPFA算法——最短路径
    POJ1251 Jungle Roads Kruskal+scanf输入小技巧
    MongoDB--关于数据库及选择MongoDB的原因
  • 原文地址:https://www.cnblogs.com/sunbr/p/11256129.html
Copyright © 2011-2022 走看看