It's a bit hard to help without any information, like the erroneous code and what you want to do there.
Here's a guess:
You want to convert an int
to a CString
, somehow like this:
int i = 42;
CString str = (CString)i;
If you're using the MFC/ATL CString you could try the following
int i = 42;
CString str;
str.Format("%d", i);
CString::Format takes a format string like printf
and stores the result in the CString.
Edit
I'm interpreting your comment below as the code that causes the error. A bit surrounding text and explanation would be nice, though.
if(iiRecd == SOCKET_ERROR || iiRecd == 0) {
iErr = ::GetLastError();
AfxMessageBox(CString(iErr));
goto PreReturnCleanup;
}
Try to change it to
if(iiRecd == SOCKET_ERROR || iiRecd == 0) {
iErr = ::GetLastError();
CString msg;
msg.Format("%d", iErr);
AfxMessageBox(msg);
goto PreReturnCleanup;
}
One general comment on the goto PreReturnCleanup;
: You may want to take a look at the RAII-Idiom as a (imho) better way to do such cleanup.