SyntaxHighlighter

Tuesday, April 21, 2009

C++: Increasing void pointer position

I became better friends with C++ today, but somehow I don't think this relationship is going anywhere.

Managed to crack this little stupid nut though. If you have a void pointer (dynamic array) you can increase it as follows:
void* ptr;            // Say of type char
(*(char*)ptr) += 100; // Or any integer

No comments: