我可以使用Double
CString
转换为_ecvt
result_str=_ecvt(int,15,&decimal,&sign);
那么,是否有类似上述方法将int
转换为CString
?
答案 0 :(得分:50)
这是一种方式:
CString str;
str.Format("%d", 5);
在您的情况下,请尝试_T("%d")
或L"%d"
而不是"%d"
答案 1 :(得分:5)
如果您想要与您的示例更相似的内容,请尝试_itot_s。在Microsoft编译器上_itot_s指向_itoa_s或_itow_s,具体取决于您的Unicode设置:
CString str;
_itot_s( 15, str.GetBufferSetLength( 40 ), 40, 10 );
str.ReleaseBuffer();
它应该稍快一些,因为它不需要解析输入格式。