What is the easiest way to convert from int to equivalent string in C++. I am aware of two methods. Is there any easier way?
int
string
(1)
I think using stringstream is pretty easy:
stringstream
string toString(int n) { stringstream ss(n); ss << n; return ss.str(); } int main() { int n; cin >> n; cout << toString(n) << endl; return 0; }