int2string

This is a discussion on int2string within the C++ Programming forums, part of the General Programming Boards category; is there a function to do that in C++ thanks...

  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,136

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

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21