Reason for not being able to set pointer-to-pointer = 2D array

I have thought and read about this for a while now. An int **p cannot be set equal to int A[2][3] by doing p=A even though it is possible to create a 2D array from int **p. Is the reasoning below correct for dynamic array created using p:

p is an array of pointers (not int) and contiguous in memory.
once allocated *p is an array of int and contiguous in memory.
address of p, *p and **p are different while address of A, A[0] and A[0][0] are same.

for this dynamic array p[1] and p[2] differ by pointer size only. However, for static array A[0] and A[1] differ by sizeof(int)*2 which is different from pointer size. Thus, the pointer-to-pointer is not able to fathom the "inner dimension(s)" of the array and thus cannot be set equal to it.

This difference means that a pointer of (*q)[3] can be set equal to A but not **p and that q[0] is NOT same as p[0] i.e difference in type.

Correct?
Last edited on
Topic archived. No new replies allowed.