Displaying and storing memory addresses
BlitzMax Forums/BlitzMax Programming/Displaying and storing memory addresses
| ||
Hey, when using pointers i want to either: Have an array of pointers..which isn't seeming likely. Similar to the idea of: Global Array_Of_Pointer:Float Ptr[4] Instead i had the idea to do this Global Array_of_Addresses:Int [4] Global X_Ptr:Float Ptr Global X:Float X_Ptr = Varptr X[0] Array_of_Addresses[0]= X_Ptr DrawText X_Ptr,0,0 I know a pointer isn't a string, but i want it's address to be displayed and stored. How do i go about doing that? [/code] |
| ||
Is this what you want?Strict Graphics 640,480,0 Local X:Int=5 Local pX: Int Ptr = Varptr(x) Local addresses: Int Ptr[2] addresses[0]=px While Not AppTerminate() DrawText "Hex="+Hex(Int(addresses[0]))+" value="+ addresses[0][0],0,0 Flip Wend Doug Stastny |
| ||
I might be misunderstanding what you want, but you can cast Ints and pointers to each other. ArrayOfPointers:Int[100] (...) ArrayOfPointers[3] = Int( MyPtr ) (...) MyPtr = Byte Ptr( ArrayOfPointers[3] ) |
| ||
There's nothing stopping you having an array of pointers, is there? Local myarray:Int Ptr[100] defines an array containing 100 int pointers. Same for float pointers. To display them you read the integer at their varptr ie Print Hex$(Int(VarPtr(myarray[11])[0])) 'or whichever offset no? |
| ||
haha, thanks guy. I was figuring that the complier would have said "this isn't a 2-d array" or something similar. I guess i should just give things a try before i assume they don't work. It's really starting to get to me these days. |