1. ## Memory Address of Array Question

It is late, and i was bored so i decided to go through a few tutorial quizes on this site. One question i came apon confused me, how do you get a memory address of a specific element in an array.
5. Which of the following gives the memory address of the first element in array foo, an array with 100 elements?
A. foo[0];
B. foo;
C. &foo;
D. foo[1];
It shows B as being correct, i do not understand why it is not C seeing as C has the memory address operator.

i mean if "foo;" returns the address of the first element of an array, how do you get say the 2nd element in the 3rd dimension's address.

Or is it trying to say that arrays keep all dimension's and elements in one memory location. Now that i think about it thats prob right lol... i think. Anyway, enlighten me hehe. Thanks

2. foo;

is same as:

&foo[0];

address of second array element is then:

&foo[1];

You can also use pointer syntax...

foo;

same as

foo+0;

then second element is

foo+1;

access value of second element using pointer syntax:

*(foo+1);

or using array syntax:

foo[1];

-Rog

3. 5. Which of the following gives the memory address of the first element in array foo, an array with 100 elements?
A. foo[0];
B. foo;
C. &foo;
D. foo[1];
Just to confuse you, both B and C are correct!

4. >Just to confuse you, both B and C are correct!
And yet, only B is really correct. While when used in value context, the name of an array is converted to a pointer to the first element, using the address-of operator on an array results in the address of the array itself, not the address of the first element. IIRC, the C++ standard doesn't require the address of an array to match the address of the first element of the array even though that is by far the most convenient implementation.