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