Re: Converting int to string
From: Russell Hind (no-one_at_no-where.com)
Date: 08/05/04
- Previous message: SteveK: "Re: using copy with list<string> and list<cstring*>"
- In reply to: David Mohandas: "Converting int to string"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 05 Aug 2004 08:47:34 +0100
Have a look at boost::lexical_cast. its basically a wrapper around
std::streams but is very convenient to use
http://www.boost.org/libs/conversion/lexical_cast.htm
int i = 10;
std::string s;
s = boost::lexical_cast<std::string>(i);
and works the other way round too
i = boost::lexical_cast<int>(s);
It will throw a boost::bad_lexical_cast exception if the conversion is
invalid.
Cheers
Russell
David Mohandas wrote:
> Is there a way in STL to convert integer data type to string object or do i
> have to do itoa() to do that.
>
>
- Previous message: SteveK: "Re: using copy with list<string> and list<cstring*>"
- In reply to: David Mohandas: "Converting int to string"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|