Consider the following c snippet:
int main(){
int *a = (int *)60;
int *b = (int *)40;
cout << a - b;
return 0;
}
The following code give output as 5. My understanding is int *a
defines a pointer to memory address of 60, so going by this logic the output should be 20. On outputting the values of a
and b
, it gives the hexadecimal representation of 60 (0x3c) and 40 (0x28); still the program prints 5.
Can somebody please explain the reason behind this?