输出char ×型变量:会根据变量地址寻址后输出寻到的地址内容。
其余类型输出值输出本变量内容。
代码:
1 #include<iostream>
2
3 using namespace std;
4
5 int main()
6 {
7 char *p[2]={"hello","world"};
8 char **q=p;
9
10 cout<<"p\t"<<p<<endl;
11 cout<<"p[0]\t"<<p[0]<<endl;
12
13 cout<<"*p\t"<<*p<<endl;
14 cout<<"*p[0]\t"<<*p[0]<<endl;
15
16 cout<<"q\t"<<q<<endl;
17 cout<<"*q\t"<<*q<<endl;
18 cout<<"**q\t"<<**q<<endl;
19
20 return 0;
21 }
结果:
p 0xbfdb5d34
p[0] hello
*p hello
*p[0] h
q 0xbfdb5d34
*q hello
**q h