Two-dimensional arrays:
1) define the shape as int a[2][3], at which point a represents the address of this two-dimensional array, and sizeof (a) is 24.
Second-level pointers:
1) define the shape as int **p: pointer to pointer
2) Level Two pointers cannot be replaced with two-dimensional arrays, such as int aa[2][3],**a;a=aa; is wrong, but can be replaced with int (*a) [3];a=aa.
Array of pointers:
1) define the shape as int *p[5]: Represents an array of five pointer elements, also known as a two-dimensional pointer, can and p[5][n] under certain circumstances, sizeof (p) is 20.
2) Each element is a pointer. such as P[0], p[1] are pointers.
such as Char *p[5]={
"SAF",
"Rfsdfds",
"Gjnaf",
"Asdfds",
"WEF"
};
P[0]~P[4] All represent the address of a string
3) p is equivalent to the array name is a constant can not be changed, similar to p++, p+=1 are all wrong, so p cannot be left value.
4) Substitution between pointer array and level two pointer
Char *p[5]={"SAF", "Rfsdfds", "Gjnaf", "Asdfds", "wef"};
Char **q;
q=p;//This is equivalent to the implicit conversion of P. It can also be understood that P itself is a one-dimensional array (the address of a one-dimensional array), just one more , then you can use one more one-level pointer to replace.
5) array of pointers as parameters
The function is declared void fun (char *p[]) and called Fun (p).
Array pointers:
1) defines a shape such as int (*a) [3].a is a pointer to an array, and sizeof (a) is 4.
2) numeric pointers can be replaced with multidimensional arrays, but multi-level pointers cannot be replaced with multidimensional pointers.
Such as
int (*a) [3],**aa,aaa[2][3];
a=aaa;//correct
aa=a;//Error
aa=aaa;//Error
Because A and AAA both represent an array pointer, and AA represents only a pointer to a pointer.
3) as a formal parameter
void Fun (int (*a) [3])//two-dimensional subscript must be clearly stated that the address of the subsequent compiler calculation a[i][1] is equivalent to the calculation a+i*3+1.
{
int i;
for (i=0;i<2;i++)
printf ("%d", a[i][1]);
}
int main ()
{
int a[2][3]={1,2,3,4,5,6};
Fun (a);
}
Pointer array & Array pointers