标签:malloc
# include <stdio.h>
# include <malloc.h>
void f(int* q)
{
*q = 100;
// free(q);//把q指向的内存释放掉
}
int main(void)
{
int * p= (int*)malloc(sizeof(int));//sizeof的返回值是int所占的字节数4,并将4个字节中第一个字节的地址赋值给p
*p = 10;
printf("%d\n", *p);//结果是:10
f(p);
printf("%d\n", *p);//结果是:100
return 0;
}
标签:malloc
原文地址:http://9384502.blog.51cto.com/9374502/1577204