conversion

how to convert an integer to a string????????
sprintf, stringstream, boost::lexical_cast, etc...
you can try out this:


#include <iostream>
#include <sstream>

using namespace std;

int main()
{
int number;
cin >> number;

stringstream ss;
ss << number;

string s = ss.str();

cout << s << endl;

return 0;
}
Last edited on
@vipul mehta: Thank you for helping, but I think it is best not to give out code for free. Most people (most) will just copy and paste your code without learning anything, especially those whose questions have 3+ question marks at the end...
Topic archived. No new replies allowed.