Wednesday, January 23, 2008

Converting int to string(CString) in MFC

int nVAl = 10;
CString strConverter;
strConverter.Format("%d",nVal);
::AfxMessageBox(strConverter);

another method is native itoa

int nVAl = 10;
char strBuf[3];
_itoa( nVal,strBuf,3,10); // here 10 is radix
CString strForCnvrsn(strBuf);
::AfxMessageBox(strForCnvrsn);

No comments: