I want to know how to convert a UCHAR array to a binary string in C++/MFC.
I tried some of the possibilities with Cstring but they didn't work. Please let me know why.
Here is the code which I have tried:
UCHAR ucdata[256];
ucdata[0] = 40;
char data[100];
StrCpy(data,(char *)ucData);
CString dataStr(data);
// original value
// convert to int
int nValue = atoi( dataStr );
// convert to binary
CString strBinary;
itoa( nValue, strBinary.GetBuffer( 50 ), 2 );
strBinary.ReleaseBuffer();