Getting A Second Byte Ptr from A Byte Ptr & Offset

BlitzMax Forums/BlitzMax Beginners Area/Getting A Second Byte Ptr from A Byte Ptr & Offset

Gabriel(Posted 2006) [#1]
Excuse the brainfart, I've been reading and converting CPP code all day and now I can't think in BMax again. If I have a Byte Ptr and an offset from that Byte Ptr, how can I get the Byte Ptr which takes that offset into account ( to be used with FromCString, so just dereferencing isn't enough.. it needs to go back to a Byte Ptr again. )


Azathoth(Posted 2006) [#2]
ptr2=ptr1+offset

is this what you mean?


Gabriel(Posted 2006) [#3]
Oh yeah, that does work. I wasn't aware you could play with pointers like that in BMax, and had worked out a convoluted solution involving dereferencing it and then going back to a pointer. Your method is much cleaner, thanks.


Defoc8(Posted 2006) [#4]
more importantly...i have bmax now! :] :p


Gabriel(Posted 2006) [#5]
lol


ImaginaryHuman(Posted 2006) [#6]
Note that if you add a number to a pointer, you are adding that number * sizeof the type of pointer.

BytePointer+10 is the same as Address+10
ShortPointer+10 is the same as Address+(10*2) or Address+20
IntPointer+10 is the same as Address+(10*4) or Address+40