On Mon, Jan 30, 2012 at 8:17 AM, Claude <clros@tiscali.it> wrote:
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?


Using a const char * is prone to Undefined Behaviors. If there's a way to use std::string instead, then try to do that.


But - if you must use a const char * [say for a 3rd party interface that requires it] then that's as good as any method.


Be aware of the potential for an exception, and be ready to deal with it.