#include <stdio.h>
int main(void)
{
int a[]= {15, 14, 34, 46, 69, 86, 10, 0, 4};
int *p = a; // p point to the first element of array a[0]
printf("%x\n%x\n",&p+1, &a[0]);
return 0;
}
that code will print as example
bff0e554
bff0e554
so &p+1 return the address of the first element of array. As i understand, &p return the address of that pointer and &p+1 should print the address of pointer + 1 please tell me what i missed !!
&p takes the address of p, not the value of p. That for you &p + 1 == a is pure coincidence and depends on your stack alignment. Your compiler could have sorted the both variables in another order or put a gap in between.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With