I started learning C recently, and I\'m having a problem understanding pointer syntax, for example when I write the following line:
int ** arr = NULL;
How can I know if :
- arr is a pointer to a pointer of an integer
It is always a pointer to pointer to integer.
- arr is a pointer to an array of pointers to integers
- arr is a pointer to an array of pointers to arrays of integers
It can never be that. A pointer to an array of pointers to integers would be declared like this:
int* (*arr)[n]
It sounds as if you have been tricked to use int**
by poor teachers/books/tutorials. It is almost always incorrect practice, as explained here and here and (
with detailed explanation about array pointers) here.
EDIT
Finally got around to writing a detailed post explaining what arrays are, what look-up tables are, why the latter are bad and what you should use instead: Correctly allocating multi-dimensional arrays.