method to convert integer to string

Discussion in 'C++' started by mthread, Feb 14, 2008.

  1. mthread

    mthread Guest

    Hi,
    I would like to know the method to convert integer to string.
    Thanx in advance.
     
    mthread, Feb 14, 2008
    #1
    1. Advertising

  2. mthread

    Ian Collins Guest

    mthread wrote:
    > Hi,
    > I would like to know the method to convert integer to string.


    Use a stringstream.

    --
    Ian Collins.
     
    Ian Collins, Feb 14, 2008
    #2
    1. Advertising

  3. mthread

    Ondra Holub Guest

    On 14 Ún, 08:22, mthread <> wrote:
    > Hi,
    > I would like to know the method to convert integer to string.
    > Thanx in advance.


    #include <string>
    #include <sstream>

    // Fn should return true if conversion succeeded
    template<typename INT>
    bool ToInt(const std::string& s, INT& i)
    {
    std::istringstream iss(s);
    s >> i;
    return !iss.bad();
    }
     
    Ondra Holub, Feb 14, 2008
    #3
  4. mthread

    red floyd Guest

    mthread wrote:
    > Hi,
    > I would like to know the method to convert integer to string.
    > Thanx in advance.


    I heard about this great new tool on the web that lets you search for stuff.

    It's called "Google". You really should try it.
     
    red floyd, Feb 14, 2008
    #4
  5. Gianni Mariani, Feb 14, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. les ander
    Replies:
    4
    Views:
    928
    wes weston
    Oct 5, 2004
  2. Dr. Phillip M. Feldman

    how to convert string function to string method?

    Dr. Phillip M. Feldman, Dec 7, 2009, in forum: Python
    Replies:
    8
    Views:
    385
    Bruno Desthuilliers
    Dec 8, 2009
  3. news
    Replies:
    2
    Views:
    1,139
  4. Sam Roberts
    Replies:
    2
    Views:
    120
    Carlos
    Nov 26, 2004
  5. Randy Kramer
    Replies:
    12
    Views:
    409
    Robert Klemme
    Oct 25, 2007
Loading...

Share This Page