Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Intermediate
Sep 23, 2008

Converting Numbers to Strings

Instead of writing your own function to convert an integer or float to a string, just use the C++ class stringstream (in the sstream header).

In C++:


#include <iostream>
#include <sstream>
#include <string>
using namespace std;

void itoa(int num, string & result)
{
    stringstream converter;
    converter << num;
    result= converter.str();
}
Baddy R
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap