2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by CodeBoy101
1

Is there a way to convert from an integer to a string?

Yes, one way of doing it is ...

#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main()
{
	int x = 123;

	stringstream ss;
	string s;

	ss << x;
	ss >> s;

	cout << s;

	return 0;
}
Votes + Comments
Perfect!!!
0

Yes, one way of doing it is ...

#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main()
{
	int x = 123;

	stringstream ss;
	string s;

	ss << x;
	ss >> s;

	cout << s;

	return 0;
}

That worked perfectly, thanks!! :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.