sizeof
returns the size in bytes: and that is absolutely what you should follow.
When you got the result:
size of a is 1
you were subtracting pointers, which returns "the number of the item the pointer points to" between them. So if you have two
pointer-to-int
values, and you subtract them, you get the
number of int
values between the two pointers, not the number of bytes.
Think about it:
p1 = p1 + 1;
Should move you to the next
int
value: not the second byte in the first
int
! :laugh: