动态内存可以跨函数使用

来源:互联网 发布:mac客人用户怎么退出 编辑:程序博客网 时间:2024/05/02 02:40
# include <stdio.h>
# include <malloc.h>

void f(int **q)
{
*q = (int *)malloc(sizeof(int));
**q = 5;
}

int main()
{
int *p;
f(&p);
printf("%d\n",*p);
return 0;
}
0 0
原创粉丝点击