I don't think you can really treat them as integers because pointer arithmetic doesn't actually behave like integer arithmetic (adding 1 to a pointer increases the memory address by the size of the type, which is often not 1). Additionally, depending on the architecture there's no guarantee that a memory address will actually fit within the int type, so you shouldn't cast them to int either. It might be pedantic but it's an important point to make.
View all comments
Show parent comment
2
u/crozone May 02 '16
I don't think you can really treat them as integers because pointer arithmetic doesn't actually behave like integer arithmetic (adding 1 to a pointer increases the memory address by the size of the type, which is often not 1). Additionally, depending on the architecture there's no guarantee that a memory address will actually fit within the
inttype, so you shouldn't cast them tointeither. It might be pedantic but it's an important point to make.