[help] Adding to a Existing Buffer
My brain isnt working for some reason and i dont know what is wrong...
I'm trying to add a header to this buffer once the buffer has been determined.
EXAMPLE: 00 00 00 00 = 4 bytes wich is the size i would then add +2 to make it 6..
so the new buffer would be 06 00 00 00 00 00
this seems to work but the new buffer just gives junk data in the array..
like... 45 23 00 00 00 00 = 6 size....
instead of it being 06 00 00 00 00 00
I'm trying to add a header to this buffer once the buffer has been determined.
EXAMPLE: 00 00 00 00 = 4 bytes wich is the size i would then add +2 to make it 6..
so the new buffer would be 06 00 00 00 00 00
Code:
usigned int Size; unsigned char * newbuffer = new unsigned char[ Size + 2 ]; int m = Size + 2; // copy data from the Buffer to newbuffer memcpy( newbuffer + 2 * sizeof( unsigned char ), Buffer, sizeof( unsigned char ) * Size ); // swap buffers delete [] Buffer; Buffer = newbuffer; Size = m;
like... 45 23 00 00 00 00 = 6 size....
instead of it being 06 00 00 00 00 00