Convert Int to String

This is a discussion on Convert Int to String within the C++ Programming forums, part of the General Programming Boards category; I had to convert an int element of an array to a string...so this is how I did.... string somestring ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    1

    Convert Int to String

    I had to convert an int element of an array to a string...so this is how I did....

    string somestring = IntToString(xyz[i]);

    #include <sstream>

    string IntToString(int num)
    {
    ostringstream myStream; //creates an ostringstream object
    myStream << num << flush;
    return(myStream.str()); //returns the string form of the
    }

    I used the above mentioned function....is there any other way to do it.

    Anyone...thanks

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    You could use the _itoa() function.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to combine these working parts??
    By transgalactic2 in forum C Programming
    Replies: 0
    Last Post: 02-01-2009, 08:19 AM
  2. Replies: 8
    Last Post: 04-25-2008, 03:45 PM
  3. Debug Error Really Quick Question
    By GCNDoug in forum C Programming
    Replies: 1
    Last Post: 04-23-2007, 01:05 PM
  4. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 12:58 PM
  5. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM

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