指针*p,p,&p等辨别

 1 #include<iostream>
 2 #include<iomanip>
 3 #include<cmath>
 4 using namespace std;
 5 int main()
 6 {
 7    int *p,i=1;
 8    p=&i;
 9    cout<<"*p: "<<*p<<endl<<"&p: "<<&p<<endl<<"p:  "<<p<<endl<<"i:  "<<&i<<endl;
10    cout<<"*(&p):   "<<*(&p)<<endl<<"**(&p):  "<<**(&p);
11   return 0;
12 }
13 /*
14 结果:
15 *p: 1
16 &p: 0x6dfeec
17 p:  0x6dfee8
18 i:  0x6dfee8
19 *(&p):   0x6dfee8
20 **(&p):  1
21 */

 

posted @ 2019-03-13 18:15  XXrl  阅读(422)  评论(0编辑  收藏  举报