2012/1/30 Claude <clros@tiscali.it>
What is the better way for convert a numeric type into a const char *?
I use:
(boost::lexical_cast<std::string>(myNumericVar)).c_str()
It is a good idea?
Depends how you use the value.
// Safe.
puts(boost::lexical_cast<std::string>(myNumericVar).c_str());
const char* s = boost::lexical_cast<std::string>(myNumericVar).c_str();
// Don't do this! Here 's' is a dangling pointer; the string has already
// been destroyed.
puts(s);
Roman Perepelitsa.