I thought array and pointer are basically the same thing, until I run this program:
int main() {
int* a = new int(19);
int b[1];
b[0] = 19;
printf("*a: %d\n a: %p\n &a:%p\n", *a, a, &a);
printf("*b: %d\n b: %p\n &b:%p\n", *b, b, &b);
delete a;
}
output is:
*a: 19
a: 0x7f94524000e0
&a:0x7fff51b71ab8
*b: 19
b: 0x7fff51b71ab4
&b:0x7fff51b71ab4
can someone please explain why the output of &b is the same as b?
Thanks! -Erben