You can use the Format function, the example is as follows, similar to printf formatted output
int n = 10
CString str;
str.Format(_T("n=%d"),n);
MessageBox(str);
Among them, _T can be replaced with Text. The function here is adaptive encoding (multi-byte and wide-byte). For details, please refer to the Windows character set