#include <cstdio>
typedef struct {
int a;
int b;
int c;
} Foo;
int main() {
Foo foo[42];
printf("foo = %p\n", foo);
printf("&foo = %p\n", &foo);
return 0;
}
When I compile this program with g++ and run it, it produces the following output.
foo = 0xbf8caea8
&foo = 0xbf8caea8
This is not what I expected. When I derefence foo, I would expect to get the value of foo[0].a and when I dereference &foo, I would expect to get a pointer on foo[0].a.
How can these two pointers be equal?