In the Below code , each location can hold 32 bit signed data. So, why doesn't the value a1 i.e 20 get stored at consecutive address de9? Array should store the data at consecutive memory location right? I know that the sizeof(int) in this online gdb compiler is 4 bytes but how can it be related to the storing of 20 at 4 locations away? Am I missing some basic concepts?
int main()
{
int a[2]= {214748368,20};
void *ptr1 = &a;
void *ptr2= &a;
ptr1++;
ptr2 = ptr2;
printf("%d \n", *(int*)ptr2);
printf("\n Pointer table");
printf("\n Data : %d at address : %p", *(int*)ptr2, ptr2);
ptr2=ptr2+1;
printf("\n Data : %d at address : %p", *(int*)ptr2, ptr2);
ptr2=ptr2+1;
printf("\n Data : %d at address : %p", *(int*)ptr2, ptr2);
ptr2=ptr2+1;
printf("\n Data : %d at address : %p", *(int*)ptr2, ptr2);
ptr2=ptr2+1;
printf("\n Data : %d at address : %p", *(int*)ptr2, ptr2);
return 0;
}