#include <stdio.h>
int main(void)
{
int a[5]={1,2,3,4,5};
int *ptr=(int*)(&a+1);
printf("%d %d\n",*(a+1),*(ptr-1));
return 0;
}
Output:
2,5
I could not understand how the *(ptr-1) evaluated to 5 (correct output). But when I manually
did it was 1. My understanding is *(ptr-1) will get evaluated to *(&a+1-1) which would be
*(&a) which is 1.
Please help me to understand this concept.
(&a + 1) != (&a[0] + 1)