1#include <iostream>
2#include<string>
3using namespace std;
4int main()
5{
6int i = 11;
7float f = 12.3;
8string str = to_string(i);
9strinf fstr = to_string(f);
10}
1// ----------------------------------- C++ 11 and onwards
2// EXAMPLE
3#include <string>
4int iIntAsInt = 658;
5std::string sIntAsString = to_string(iIntAsInt);
6
7/* SYNTAX
8to_string(<your-integer>)
9*/
10
11// ----------------------------------- BEFORE C++ 11
12// EXAMPLE
13#include <sstream>
14#include <string>
15int iYourInt = 5;
16std::stringstream ssYourInt_AsStream << iYourInt;
17std::string sYourInt_AsString = ssYourInt_AsStream.str();
1#include <iostream>
2#include <boost/lexical_cast.hpp>
3using namespace std;
4int main()
5{
6 int i=11;
7 string str = boost::lexical_cast<string>(i);
8cout<<"string value of integer i is :"<<str<<"\n";
9
10}