Hello all !
I am reading my first c book, and I could almost say "so far so good". Some serious doubts are starting to arise though. Most of them regarding pointers (I know you expected this ) and arrays.
I know a pointer is a variable that contains a memory address as its value. I also know (tell me if I am wrong) that the name of an array is a pointer variable, pointing to the first element of the array. Well, I think I got that.
But... letīs consider the following code:
#include <stdio.h>
int main (void)
{
int a [5] = {0,1,2,3,4};
printf ("%p\n", &a [0]);
printf ("%p\n", &a);
return 0;
} /* main */
If 'a' is the name of the array, that is it is a pointer pointing to a[0], how can it be that it is located at same memory address as the first element in the array? I mean both a and a[0] are located at same memory address !!
Any explanation will be appreciated.
Thanks in advance !!