Sure. By definition, the expression "(ptr3+1)-ptr3" yields a value which when added to ptr3 yields ptr3+1, and that value is simply 1 since the scaling by sizeof(*ptr3) is implied in the addition.
When you do the (unsigned) typecast, the pointer type is lost, so the result is a number which when added to an integer containing the bit pattern of ptr3 will yield an integer containing the bit pattern of (ptr3+1). The addition is done on the pointer type, and gets the implied scaling, but the subtraction is simply the difference between two integers.
|