access variable using pointer
BlitzMax Forums/BlitzMax Programming/access variable using pointer
| ||
SuperStrict Local a:Int = 123 Local b:Int Ptr Local c:Int Ptr Ptr b=Varptr(a) c=Varptr(b) but how can i change the value 123, using c variable? in C++ is could do this: **c=777; |
| ||
This works. Don't know if there's a better way.SuperStrict Local a:Int = 123 Local bk:TBank = CreateStaticBank(Varptr(a),4) PokeInt bk,0,125 DebugLog a |
| ||
c[0][0] refers to a. This array-style syntax for dereferencing pointers is a little awkward. I think it is meant to discourage the use of pointers, although they are available if you really want them. |
| ||
hm ;-) i think we need a new keyword. VARPTR "add" 1 pointer level to a variable/pointer C++ do the same with &-symbol VARSOMETHING (or a symbol *) should "remove" 1 pointer level from pointer C++ do the same with *-symbol int a; int *b; int **c; b=&a; c=&b; b=*c; or is c[0][0] official? |