Mail Archives: djgpp/2003/03/10/10:09:15
"Joel_S" <jbs30000 DOT news DOT invalid AT web2news DOT net> wrote:
> I don't think there's a built in version of a float
> to string
> conversion routine, but does anybody have any code,
> or know a library
> that contains such a routine? Thanks.
If you're using C++, just use an ostringstream:
#include <string>
#include <sstream>
int main()
{
using namespace std;
float f = 7.25;
ostringstream os;
os << f;
string s = os.str();
// s now holds the string
// representation of f
}
For more info, take a look at sections 38.1 - 38.3 of
the C++ FAQ:
http://www.parashift.com/c++-faq-lite/
Best regards,
Tom
__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com
- Raw text -