herrcho <he*********@ko rnet.net> scribbled the following:
#include <stdio.h>
int multi[2][4];
int main()
{
printf("\nmulti = %u",multi);
multi decays into a pointer to an array of 4 ints here.
printf("\nmulti[0] = %u",multi[0]);
multi[0] decays into a pointer to an int here.
printf("\n&mult i[0][0] = %u\n",&multi[0][0]);
&multi[0][0] is the same thing as multi[0].
return 0;
}
Technically you are invoking undefined behaviour by printing pointers
with %u. You should use %p and cast the arguments to (void *).
But your compiler might well ignore this and print the correct addresses
anyway.
the 3 statements above shows the same result.
i can understand the second and the third result in same output.
BUT
the first and the second ..
as far as i know, multi is the pointer to the first element of the
array,
so multi is same as &multi[0]
then, why multi == multi[0]
please teach me the right thing.. TIA ^^
This is because multi and multi[0] both decay into pointers when given
as parameters, and the first element of an array is required to begin
at the same address as the array itself.
--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
|
http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"I am not very happy acting pleased whenever prominent scientists overmagnify
intellectual enlightenment."
- Anon