I'm new to C++ and am struggling with a piece of code. I have a Static text in a dialog, which I want to update on button click.
double num = 4.7;
std::string str = (boost::lexical_cast<std::string>(num));
test.SetWindowTextA(str.c_str());
//test is the Static text variable
However the text is displayed as 4.70000000000002. How do I make it look like 4.7.
I used .c_str()
because otherwise a cannot convert parameter 1 from 'std::string' to 'LPCTSTR'
error gets thrown.