cancel
Showing results for 
Search instead for 
Did you mean: 

pointer typecasting

Disha
Associate II

As per image sub=7(not typecasted), sub1=28(typecasted). I don't understand why is sub giving wrong value I understand I have not typecasted but,each pointer variable is holding 4 byte value (i.e int type) then,typecasting must not be required isnt it? where am I going wrong?

0693W000003QfNyQAK.png

1 REPLY 1
hs2
Senior

The difference of int pointers (pointers to ints which are 32 bit wide for a 32 bit processor) is counted in ints.

As defined by the C standard regarding pointer arithmetic.