int m_value = 1; void func(int *p) { p = &m_value; } int main(int argc, char *argv[]) { int n = 2; int *pn = &n; cout << *pn << endl; func(pn); cout << *pn <<endl; return 0; }
看一下输出结果
2
2
-------其实上面这些例子,看一百次,我个人觉得,也看不出实际意义
#include <stdio.h>
#include <malloc.h>
#include <string.h>
void Allocate(char* p,int size){
printf("
%x",&p);
printf("
%x",p);
p=(char*)malloc(size);
}
void Free(char* p){
free(p);
}
void main()
{
char *str=NULL;
printf("
%X",&str);
printf("
%X",str);
Allocate(str,100);
strcpy(str,"Hello World!");
printf("
%s",str);
Free(str);
printf("
str=%s",str);
}
------上面的这样的错误案例,才有实际的教学意义!!!
http://www.cnblogs.com/li-peng/p/4116349.html
http://blog.csdn.net/whzhaochao/article/details/12891329 ----经典,用事实说话