Raman009 wrote: |
---|
however the thing about a and &a seems a bit NOT clear . |
Read what Disch wrote, his answer is pretty much spot-on
a refers to the address of the first element of the array ie &a[0] , Isn't it ? |
a
is an array. When used as an argument to a function or operator that doesn't accept arrays, but accepts pointers,
&a[0]
is substituted by the compiler, which first constructs a nameless temporary pointer to the first element, and then passes that pointer to the function/operator by value.
&a should refer to the address(memory location) of a ie pointer to a which further points to the int . In other words , pointer to pointer to int .
|
No, on two counts:
First, even if the address-of operator didn't work with arrays, this would resolve to
&(&a[0])
, which would attempt to produce the address of a nameless temporary pointer constructed by the expression
&a[0]
. But since nameless temporaries have no addresses, this
&(&a[0])
doesn't even compile.
Second, since the address-of operator actually does work with arrays,
&a
simply constructs a pointer to the array
a
.
and I am still trying to understand int(*)[4] |
That is the type of the pointer to an array of 4 ints.