Re: Converting int to string

From: Russell Hind (no-one_at_no-where.com)
Date: 08/05/04

  • Next message: Frank Yeh: "Re: Converting int to string"
    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.
    >
    >


  • Next message: Frank Yeh: "Re: Converting int to string"

    Relevant Pages