howardsd
asked on
CString to byte array at specific array index
I need to put a CString into a byte array at a specific index. I've tried the below method, but it seems to tack on 2 extra bytes of gibberish to the end of the array.
BYTE bArrTemp[18];
CString szWrite;
memset(bArrTemp,0x00,18);
memcpy(&bArrTemp[2],szWrit e,szWrite. GetLength( ));
bArrTemp[0] = TAG_GUID;
bArrTemp[1] = LEN_GUID;
BYTE bArrTemp[18];
CString szWrite;
memset(bArrTemp,0x00,18);
memcpy(&bArrTemp[2],szWrit
bArrTemp[0] = TAG_GUID;
bArrTemp[1] = LEN_GUID;
what's the possible length of the CString? if it's more than 15, you'll have a problem.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
BTW, why aren't you simply using
szWrite[0] = TAG_GUID;
szWrite[1] = LEN_GUID;
instead?
szWrite[0] = TAG_GUID;
szWrite[1] = LEN_GUID;
instead?
ASKER
It was the damn null terminator I wasn't copying. Duh.
Thnx!
Thnx!
ASKER