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
| ||
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. ) |
| ||
ptr2=ptr1+offset is this what you mean? |
| ||
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. |
| ||
more importantly...i have bmax now! :] :p |
| ||
lol |
| ||
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 |