I have this below code:
main()
{
int pt = {0}, *ppt = &pt;
char *p1 = NULL, *p2 = NULL;
p1 = (char*)(ppt);
p2 = (char*)(ppt+1);
printf("%p\n",p1);
printf("%p\n",p2);
printf("%d",(p2-p1));
}
This gives me the size of the variable as expected. But I don't understand how this works. The p1 and p2 as to be char. Why? If I change that to short or int, I get the result as 1, though the address has the same difference.