Could someone please explain why the pointer ptr assignment causes ptr to point at one memory location past the array last element?
I have output the memory locations just for verification. I thought that &a could point to the first element of the array.
0022FF60 0022FF64 0022FF68 0022FF6C
0022FF70
4 3
Code:
#include <stdio.h>
int main(void)
{
int a[4] = {1,2,3,4};
int *ptr = (int*)(&a+1); // Why does this assignement put the ptr pointer
// to point at one memory location after the array???
int *p = a;
printf("%p %p %p %p\n",p,(p+1),(p+2),(p+3));
printf("%p \n",ptr);
printf("%d %d", *(a+3), *(ptr-2) );
return 0;
}