If you try that piece of code
#include<stdio.h> int main() {
// Pointer to an integer
int *p;
// Pointer to an array of 5 integers
int (*ptr)[5];
int arr[] = { 3, 5, 6, 7, 9 };
// Points to 0th element of the arr.
// Points to the whole array arr.
ptr = &arr;
printf("p = %p, address of P = %p\n", p, &p);
return 0; }
You will get something like p = 0x7fff8e9b4370, P address = 0x7fff8e9b4340
which means the address of pointer P is something and the data inside it is another
but if you try the same with the pointer of the array like this
#include<stdio.h> int main() {
// Pointer to an integer
int *p;
// Pointer to an array of 5 integers
int (*ptr)[5];
int arr[] = { 3, 5, 6, 7, 9 };
// Points to 0th element of the arr.
p = arr;
// Points to the whole array arr.
ptr = &arr;
printf("arr = %p, arr address = %p\n", arr, &arr);
return 0; }
You will get something like arr = 0x7ffda0a04310, arr address = 0x7ffda0a04310
So how come that a pointer data is the same the pointer Address in memory ?!! when we dereference the address of the arr pointer we should get the number 3 but as i understand from this is the address location 0x7ffda0a04310
in the memory has 0x7ffda0a04310
as a data
so where i am mistaken ?
int (*ptr)[5]
has? – jwdonahue