int main() { int i=10; int *p=&i; int **pp=&p; int ***ppp=&pp; cout<<p<<":"<<*p<<":"<<endl; cout<<pp <<":"<<*pp<<":"<<**pp<<":"<<endl; cout<<ppp<<":"<<*ppp<<":"<<**ppp <<":" <<***ppp<<":" <<endl; return 0; }
数组指针
void main() { int a[3][3]={ 1,2,3,4,5,6,7,8,9}; int (*q)[3];//数组指针 q=a; cout<<q<<endl;//0012ff24 cout<<*q<<endl;//0012ff24 cout<<*q+1<<endl;//0012ff28//p+4bit cout<< *q[0]<<endl;//1 cout<< **q <<endl;//1 等同上 cout<<**q+100<<endl;//101 cout<<**(q+1)<<endl;//4 cout<<*(*q+1)<<endl;//2 cout<<q+1<<endl;//0012ff30 cout<<*(q+1)<<endl;//0012ff30 cout<<q+3<<endl;//0012ff48, cout<<*q+1<<endl; }
void main() { int a[3][3]={ 1,2,3,4,5,6,7,8,9}; int *q[3];//指针数组 for(int i=0;i<3;i++) q[i]=a[i]; cout<<q<<endl;//ff18 q本身 cout<<*q<<endl;//ff24 a[0][0]地址 cout<<*q+1<<endl;//ff28 a[0][1] cout<<*(q+1)<<endl;//ff30 a[1][0] cout<<**q<<endl;//1 a[0][0]的值 cout<<*(*q+1)<<endl;//2 a[0][1]的值 cout<<**(q+1)<<endl;//4 a[1][0]的值 }
#include<stdio.h> #include<iostream> using namespace std; char *c[]={"ENTER","NEW","POINT","FIRST"}; char **cp[]={c+3,c+2,c+1,c}; char ***cpp=cp; int main(void) { printf("%s ",**++cpp);//POINT ++cpp printf("%s ",*--*++cpp+3);// ER printf("%s ",*cpp[-2]+3);//ST printf("%s\n",cpp[-1][-1]+1);//EW return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/fujinlong520/article/details/48084943