Last active
October 29, 2017 12:07
-
-
Save Alynva/6776aeb4c359ee32923ab2b0b8d6fe17 to your computer and use it in GitHub Desktop.
Convert anything to string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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