Change what a pointer points to after you return it in C++ -


i'm working on c++ project , need little sanity check , on it. want return void* pointer memory location in array (which i'll

 void* pointer = (void*) (array+index); 
). array of chars indexing/byte numbering works out pretty nicely.

however, want able change memory location points later on (a different spot in array) response conditions in code. there way this? i'm messing around void** pointers , trying return reference spot in memory stored pointer, can change memory pointer stored , change pointer read. i'm having trouble on syntax this, though, , i'm not entirely sure it's possible.

i'm working within rigid constraints , can't around fact have return void* pointer, otherwise think there nicer ways around problem.

any appreciated!

you can reassign pointer:

char array[1200];  void * p = array + 17;  // later:  p = array + 29; 

(no need cast, since object pointers implicitly convertible void pointers.)


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -