Link to home
Start Free TrialLog in
Avatar of howardsd
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],szWrite,szWrite.GetLength());

bArrTemp[0] = TAG_GUID;
bArrTemp[1] = LEN_GUID;

Avatar of howardsd
howardsd

ASKER

My mistake, it's actually tacking on a lot of extra bytes of gibberish.
what's the possible length of the  CString?  if it's more than 15, you'll have a problem.

ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW, why aren't you simply using

szWrite[0] = TAG_GUID;
szWrite[1] = LEN_GUID;

instead?
It was the damn null terminator I wasn't copying.  Duh.

Thnx!