前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >跨函数使用内存案例

跨函数使用内存案例

作者头像
孙晨c
发布2019-09-10 19:15:07
2980
发布2019-09-10 19:15:07
举报
文章被收录于专栏:无题~无题~
代码语言:javascript
复制
 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 }
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-07-27 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档