Skip to content

Instantly share code, notes, and snippets.

@Alynva
Last active October 29, 2017 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Alynva/6776aeb4c359ee32923ab2b0b8d6fe17 to your computer and use it in GitHub Desktop.
Save Alynva/6776aeb4c359ee32923ab2b0b8d6fe17 to your computer and use it in GitHub Desktop.
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