I have a unsigned c++ char buffer
unsigned char* pBuffer = new unsigned char [1024];
I want to save the pBuffer pointer in the first few bytes of the newly allocated buffer by using an assignement rather than memcpy- ie
*(unsigned char*) &pBuffer[0] = pBuffer;
I am not able to get the sytax right. Appreciate help with the correct syntax for doing this.
Visual Studio 2010
I don’t know why you would want to do this, but I can think of a few oddball reasons, so:
You want the compiler to reinterpret the pointer as a
unsigned char**, and store the value ofpBufferin the 0-index slot.You said you’re indexing a “linked list” with multiple pBuffers. In that case, you should not use reinterpret_cast. Instead: