I am using Visual Studio c++ and want to convert the Cstring to Byte. I have written this code but it gave me error in the second line that \"data\" is undefined.
Probably you didn't include the cruicial header
#include int main() { CString data = _T( "OK"); LPBYTE pByte = new BYTE[data.GetLength() + 1]; memcpy(pByte, (VOID*)LPCTSTR(data), data.GetLength()); return 0; }
This code works fine.