the difference between an array pointer and an array of pointers is: The array pointer p is a pointer, and the pointer array p is an array that holds n pointer variables.
One, array pointers
int (*p) [n]
emphasis: () High priority ([], () The priority is the same, but they are in the direction from left to right, so first run the parentheses in the *pFirst, it shows that P is a pointer to a one-dimensional array of integers, and the length of the one-dimensional array is n, which can be said to be the step of P. That is, when the p+1 is executed, p crosses the length of the N-Integer data (n*sizeof (int)).
To assign a two-dimensional array to a pointer, you should assign a value like this:
int a[3][4];
int (*p) [4];The statement defines an array pointer that points to a one-dimensional array of 4 elements.
p = A;Assigns the first address of the two-dimensional array to p, i.e. a[0] or &a[0][0]
p++;//<=>A[1]<=>P[1]
When used to point to a two-dimensional array, the reference is the same as the array name reference.a<=>p。 For example, to represent an array of I rows J column an element A[i][j]:
P[i][j]<=>a[i][j] <=>* (p[i]+j)<=>* (a[i]+j) <=> * (* (p+i) +j)<=>* (* (a+i) +j) <=> (* (P+i)) [j]<=>(* (A+i)) [j]
Two, array of pointers
int *p[n]
Focus: [] High priority, first combined with p to an array, and then by int* that this is an integer pointer array that has an array element of n pointer types: that is, it is an array of n pointers.
This assignment is also wrong: P=a because P is a right value, P's value only exists p[0], p[1], p[2]...p[n-1], and they are pointer variables that can be used to hold variable addresses. But can be so *p=a; Here *p represents the value of the first element of the pointer array, the value of the first address of a.
To assign a two-dimensional array to an array of pointers:
int *p[3];
int a[3][4];
for (i = 0; i < 3; i++)
P[i] = A[i];
Here int *p[3] represents a one-dimensional array containing three pointer variables, respectively p[0], p[1], p[2], and by default these three pointer variables all point to NULL, so assign values separately.