I've just been helping someone out with some code. He had this:
char dataArray[10];
Then wanted to get a pointer to the start of the array. Rather than use:
&dataArray[0]
or just
dataArray
He used
&dataArray
Did he end up with a pointer to a pointer there? I'm not sure what &dataArray
would give him.
&dataArray[0]
is of typechar *
. That is a pointer tochar
.dataArray
is of typechar[10]
&dataArray
will be of typechar (*)[10]
. That is a pointer-to-array.Apart from that, the value will be same, i.e., they point to the same address but their types need not be compatible.
None of them is a pointer-to-pointer here. They are just pointer with different types.
Note: Because the array decaying property,
char [100]
will decay to achar *
, for example, when passed as an agument of a function.