Let me explain with the example.
int main()
{
int arr[] = { 1, 2, 3};
int *ptr = NULL;
printf("addr arr : %p\naddr ptr : %p\n", arr, ptr);
/*
The output will addr arr : SOME_ADDR and addr ptr : (nil)
So the name of array will give self address. But the name of pointer will give the address to which it
pointing, not self address. For that you need to do " printf("ptr_addr : %p\n", &ptr);"
*/
ptr = arr;
printf("addr arr : %p\naddr ptr : %p\n", arr, ptr);
/*
This will print same address which belongs to arr. See it by your self.
*/
return 0;
}
Some time array can be used as a pointer and vice-verse. For example.
int array[] = { 1, 2, 3}
printf(" array[0] : %d, array[1] : %d, array[2] : %d\n", array[0], array[1], array[2]);
printf(" array[0] : %d, array[1] : %d, array[2] : %d\n", *array, *(array + 1), *(array + 2));
/* Both are same. */
int *ptr = array;
printf(" ptr[0] : %d, ptr[1] : %d, ptr[2] : %d\n", ptr[0], ptr[1], ptr[2]);
/* It will print the same output as above. */
A pointer can point to an array, but the same for array is not ture, i.e
int array1[] = { 1, 2, 3};
int array2[] = { 4, 5, 6};
int *ptr = array1;
ptr = array2; /* This is ok, you can change the ptr pointing to some other location */
/* But same is not possible for array */
array1 = array2; /* It will give to error */
Hope your doubt will be clear after this.