Skip to content

Instantly share code, notes, and snippets.

Last active Oct 29, 2017
What would you like to do?
Convert anything to string
#include <string> // std::string
#include <iostream> // std::cout
#include <sstream> // std::ostringstream
using namespace std;
template <typename T>
string to_string ( T Number ) {
string Result;
ostringstream convert;
convert << Number;
Result = convert.str();
return Result;
int main() {
string s = to_string(2);
cout << s << endl;
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment