I'm trying to use memcpy to convert a TCHAR array into a BYTE array but the memcpy function is only copying 1 TCHAR from the tchar array into the byte array.
I have no idea why this is happening.
Here is a code snippet.
TCHAR test[] = L"This is a test string, its purpose is to do some testing!";
DWORD testSizeBytes = sizeof(TCHAR) * lstrlen(test);
LPBYTE byteArray = new BYTE[testSizeBytes+1];
memcpy(byteArray,test,testSizeBytes);
If I used this snippet the byteArray would just contain 'T';
Any help would be appreciated.
EDIT: I fixed the issue (It was a typo). The code I wrote here works flawlessly. My compiler is in a windows VM so I had to retype it here and unknowingly fixed the typo.