Hi all,
I want to create a buffer to send to some external device. I store the values in char arrays.
I want to copy the values into one buffer with this code:
The buffer is created like this:Code:void CRobotData::GenerateBuffer(char * pBuffer) { // Declare variables int iPointerAddress = 0; // Copy all data memcpy(pBuffer + iPointerAddress, m_a, 4); iPointerAddress += 4; memcpy(pBuffer + iPointerAddress, m_b, 4); iPointerAddress += 4; memcpy(pBuffer + iPointerAddress, m_c, 4); iPointerAddress += 4; memcpy(pBuffer + iPointerAddress, m_d, 4); }
What happens is this:Code:char * pBuffer = new char[16]; ZeroMemory(pBuffer, 16);
pBuffer = "0000000000000000ýýýýÝÝÝÝA"
It is driving me crazy, why isn't the buffer 16 x 0 as it should be?
Thanks!




Reply With Quote