【发布时间】:2013-06-23 09:07:30
【问题描述】:
对不起我的英语。
我需要将double值转换为CString,因为我需要做AfxMessageBox(double_value);
我发现了这个:
std::ostringstream ost;
ost << double_value;
std::cout << "As string: " << ost.str() << std::endl;
//AfxMessageBox(ost.str()); - Does not work.
我该怎么做?
【问题讨论】:
-
当然不行 - AfxMessageBox 需要一个双精度,为什么它应该能够得到一个 cstring?
-
AfxMessageBox 不期望双...
-
@zmbq 没有 AfxMessageBox(double_value);不建议它期望双倍?
-
AfxMessageBox 需要 CString: AfxMessageBox("Text");它不是双重的
-
实际上 AfxMessageBox 需要 LPCTSTR,而不是 CString,但后者有很好的隐式转换,所以它可以工作。您的试用意味着您有 UNICODE 配置,是什么导致了错误。您可以使用 AfxMessageBoxA 代替 AfxMessageBox。当然使用接受的答案也可以。
标签: c++ type-conversion