#include <iostream> #include <stdio.h> using namespace std; int main() { int test[2][3]={{1,2,3},{4,5,6}}; int (*A)[3]; A = &test[0];// A = test cout<<(*A)[0]<<endl; cout<<(*A)[4]<<endl; cout<<**A<<endl; cout<<**(A+1)<<endl; // cout<<**(&*A+1)<<endl cout<<*(*A+1)<<endl; }
int a[]={1,2,3,4,5}; int *ptr =(int*)(&a+1); cout<<*(a+1); //2 cout<<*(ptr-1); //5
数组名a本身就是指针,再加上个&就变成了双指针,这里的双指针就是指二维数组,&a+1,就是整体数组加一行,ptr指向a的第6个元素。
*A 可以看成一个(含有3个int元素的数组的)数组名,所以类推,去掉*,等于加上&, A是双指针,加1,就是数组整体加一行。