Declares an array pointer:
This is a pointer to an array of integers of length 4
Declare an array of pointers:
int *p2[4];//pointer array
This is an array that contains 4 pointers to integers
Start P1 point to the first row of the array, and now point to the second row
The results are as follows:
P2[0] = (int*) A;
P2[0] is an integer pointer that now points to the first element of the two-dimensional array a
The complete code is as follows:
#include <cstdio>int main () {int a[2][4] = {1,2,3,4,5,6,7,8};//int (*P3) [4][5];//This is also an array pointer int (*P1) [4];//pointer to an array] int *p2[4];//pointer array int *p4 = (int*) a;p1 = a;p2[0] = (int*) a;p1++;//equivalent to p4+4, 4 units of printf were moved backwards ("%d%d%d%d \ n", (*P1) [0], ( *P1) [1], (*P1) [2], (*P1) [3]);//Print 5, 6, 7, 8 printf ("%d%d%d%d \ n", P2[0][0], p2[0][1], p2[0][2], p2[0][3]);//print 1, 2, 3 , 4 return 0;}
Run results
C-language pointer arrays and arrays pointers