Boost logo

Boost Users :

Subject: Re: [Boost-users] Conversion from numeric type to const char*
From: Jeff Flinn (Jeffrey.Flinn_at_[hidden])
Date: 2012-01-30 11:27:16


Claude wrote:
> Ok. I could use strcpy() to copy the .c_str() result in my char array?
>
> --
> View this message in context: http://boost.2283326.n4.nabble.com/Conversion-from-numeric-type-to-const-char-tp4340944p4341054.html
> Sent from the Boost - Users mailing list archive at Nabble.com.

If you absolutely need to fill a char array use std::string's copy
method for that:

char buf[100];

boost::lexical_cast<std::string>(myNumericVar).copy(buf,100);

See Josutti's The C++ Standard Library 11.2.4

Alternatively boost::iostreams::array_sink to directly stream to a char
buffer.

Jeff


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net