?
2014-06-25 07:10:12 UTC
1. To define a pointer to a pointer, you do the following:
int* p1;
int** pp2;
int pp2 = &p1;
Why is pp2 assigned to &p1? I understand that the point is to assign pp2 to the address of p1, but since p1 is a pointer, doesn't that mean that pp2 should be assigned to plain old p1 (since a pointer's address can be used without the need of the address of (&) operator).
2. When assigning a pointer to an array you do the following
int x[12];
int *q = x;
In the book I am reading, it mentions that to assign a pointer to a multidimensional array you do (not) do the following
int x[8][12];
int** q = x;
The book then mentions that this does not work (which it does not), but why would one even consider having a pointer point to an array, but have a pointer to a pointer point to a multidimensional array? I tried, after reading this, having a single pointer point to the multidimensional array, but that did not work either. Why not? The book does provide a brief explanation to why, but it is not as in depth as I would like it to be.
Thank you in advance.