下面主要以整形数据为例
#include #include using namespace std;int main(){ int a = 5; int * p = &a; cout <<"变量的取值===>a = " < <<"变量的地址===>&a = " <<&a < <<"指向变量的指针加*===>*p = " <<*p < <<"指向变量的指针名===>p = " < <<"指向变量的指针的地址&p = " <<&p < system("pause"); return 0;}
<<"指向变量的指针的地址&p = " <<&p < system("pause"); return 0;}
运行结果:
内存图示
1 #include using namespace std;int main(){ int a[5] = {1, 2, 3, 4, 5}; int *p = a; int **point = &p; cout <<"a = " < <<"p = " < <<"&p = " <<&p < <<"point = " < <<"&point = " <<&point < for (int i = 0; i <5; i++) { cout <<"&a[" <"] = " <<&a[i] < } return 0;}
<<"&p = " <<&p < <<"point = " < <<"&point = " <<&point < for (int i = 0; i <5; i++) { cout <<"&a[" <"] = " <<&a[i] < } return 0;}
参考 http://www.cnblogs.com/dzry/archive/2011/05/12/2044835.html