我是 C++ 新手,正在为一段代码苦苦挣扎。我在对话框中有一个静态文本,我想在单击按钮时对其进行更新。
double num = 4.7;
std::string str = (boost::lexical_cast<std::string>(num));
test.SetWindowTextA(str.c_str());
//test is the Static text variable
但是文本显示为 4.70000000000002。我如何使它看起来像4.7。
我使用.c_str()
了,否则cannot convert parameter 1 from 'std::string' to 'LPCTSTR'
会引发错误。