Consider the following code snippet.
int main(){
int x[2];
x[0]=100;
x[1]=200;
printf("%d\n",x);
printf("%d\n",&x);
printf("%d\n",*x);
}
The output is given as (in three lines)
6487616 6487616 100
I've read that the array name is a pointer to the first element of the array. Therefore, the value of 'x' prints a memory address. But if i try to print the address of the pointer which holds the address of the first element of the array, why does that also print the same memory address? Shouldn't it be printing another memory address, simply because in order for a variable to store a memory address it should be a pointer and that pointer variable also has a memory address in the RAM.
int main(){
int y = 10;
int *p = &y;
printf("%d\n",&y);
printf("%d\n",&p);
}
The above code gives the output as
6487628 6487616
So why doesn't this work when it comes to arrays?