I declared an array a = {1,2,3} and then take a pointer int *p = a Now p, a, &a[0] should have the same value. But when I use a for loop to print the array a, the initial value of p showing (a+4) . Code:
int a[3] = {1,2,3};
int *p = a;
for(int i=0; i<3; i++){
printf("&a[0]=%p p=%p a=%p p=%d\n", &a[0], p, a, *p++);
}
Output:
&a[0]=0061FF0C p=0061FF10 a=0061FF0C *p=1
&a[0]=0061FF0C p=0061FF14 a=0061FF0C *p=2
&a[0]=0061FF0C p=0061FF18 a=0061FF0C *p=3
Here, in first line of the output why p is not equal to 0061FF0C ?