Thread: int2string

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    71

    int2string

    is there a function to do that in C++
    thanks

  2. #2
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    In C++, you can use the string stream classes, like so:

    Code:
    int intval = 668;
    std::ostringstream stm;
    stm << val;
    std::string rslt = stm.str();
    You can also use the istringstream class to convert strings to numeric types.

    Both these classes are derived from a base class called ios_base. This is were you will find all the methods to set the format (preceision etc.) of your resulting strings.

  3. #3
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138

  4. #4
    Registered User
    Join Date
    May 2002
    Posts
    71
    thanks bros

Popular pages Recent additions subscribe to a feed