How to convert integer to string in C++?

There are 2 approaches to convert integer variables to string. Both the approaches with a sample code are mentioned below. Approach-1 #include<iostream> #include<string> using namespace std; void main() { int n= 1; string s= to_string(n); cout << s; } Approach-2 #include<iostream> #include <sstream> #include <string> using namespace std; int main() { int n = 17; … Read more