When I declare an array in C:
char a[] = "something";
I understand that a is implicitly a const character pointer, i.e. a is of the type: (char * const)
But then why does the following statement result in the compiler warning about incompatible pointer types?
char * const * j = &a;
The only way I've managed to get rid of it is by explicitly casting the right hand side to (char * const *).
I hypothesized that & operator returns a constant pointer and tried:
char * const * const j = &a;
without success.
What is going on here?
ais not a pointer, it's an array. In some situations, it will "decay" to a pointer toa[0], or achar *... but&adoes not give the address of a pointer, it gives the address of the array... which is the same address as&a[0], but a different type, as it points to an array and not to achar.char * const * const jis a pointer to a pointer, which&ais not.