Reprinted from: http://blog.csdn.net/kaiming2008/article/details/5617155
Note how pointer arrays and array pointers point to two-dimensional arrays, respectively.
#include <stdio.h>
Main ()
{
static int m[3][4]={0,1,2,3,4,5,6,7,8,9,10,11};/* defines a two-dimensional array m and initializes the */
int (*p) [4];//array pointer p is a pointer to a one-dimensional array with 4 int elements per one-dimensional array
int i,j;
int *q[3];//pointer array q is an array, array element is pointer, 3 int pointer
P=m; P is a pointer that can point directly to a two-dimensional array
printf ("--array pointer output element--/n");
for (i=0;i<3;i++)/* Outputs the values of each element in a two-dimensional array */
{
for (j=0;j<4;j++)
{
printf ("%3d", * (* (p+i) +j));
}
printf ("/n");
}
printf ("/n");
for (i=0;i<3;i++,p++)//p can be seen as a row pointer
{
printf ("%3d", **p);//The first element of each line
printf ("%3d", * (*p+1));//The second element of each row
printf ("%3d", * (*p+2));//The third element of each row
printf ("%3d", * (*p+3));//Fourth element of each row
printf ("/n");
}
printf ("/n");
printf ("--pointer array output element--/n");
for (i=0;i<3;i++)
Q[i]=m[i];//q is an array, element Q[i] is a pointer
for (i=0;i<3;i++)
{
for (j=0;j<4;j++)
{
printf ("%3d", Q[i][j]);//q[i][j] can be replaced by * (Q[I]+J)
}
printf ("/n");
}
printf ("/n");
Q[0]=M[0];
for (i=0;i<3;i++)
{
for (j=0;j<4;j++)
{
printf ("%3d", * (Q[0]+j+4*i));
}
printf ("/n");
}
printf ("/n");
}
C,c++ pointer arrays and array pointers