Reputation: 362
I am new to vc++. How to convert UCHAR *
value to CString
and CString to UCHAR *
CString str;
UCHAR * pBuffer;
......Memmory allocation..
str.format(_T("%d"),pBuffer);
But its not working. Second data may be string or int so how to do conversion in proper way.
Upvotes: 0
Views: 721
Reputation: 596397
Second data may be string or int so how to do conversion in proper way.
You have to interpret the UCHAR*
data as a proper data type when formatting it, eg:
// if pBuffer contains 'int' data...
str.format(_T("%d"), *(int*)pBuffer);
// if pBuffer contains 8bit 'char' data w/ a null terminator...
str.format(_T("%hs"), (char*)pBuffer);
Or:
// if pBuffer contains 8bit 'char' data w/o a null terminator...
str.format(_T("%*hs"), iBufferLen, (char*)pBuffer);
And so on...
Upvotes: 1