I totally understand what is "int *p[3]
" ( p is an array of 3 pointer meaning we can have 3 different rows of any number of ints by allocating the memory as our size of different rows).
My confusion lies with " int (*p)[3]
" what does this signifies? Is it like "p" stores the address of 3 contiguous memory of int or something else?
Please clarify and also how to use use in program to distinguish them.
Thanks a lot in advance.
@revised
Sorry for putting up duplicate question. I didn't search my doubt intensively. But my doubt still remains as novice programmer. I went through both the pages of Q/A C pointer to array/array of pointers disambiguation
and
second link partly clears the doubt so eliminate my doubt please explain above question in reference to stack and heap: for example
int *p[3]; // (1)
take 12(3*4bytes) bytes of stack and for heap will depend on run-time. Now for
int (*p1)[3]; //(2)
(2) using "new" would be one as
p1 = new int[7][3]; // (3)
given in one of the answer of link int (*p) [4]? ; Now my question is since " int (*p1)[3]; //(2) " is a pointer to am array of 3 ints so how much memory will be taken by p1 at compile time as eq(3) can a also be replaced by
p1 = new int[n][3]; // (3) where n is an integer
so what then?
Please explain.