Wednesday, October 7, 2015

String to int and Int to string c++

#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
stringstream ss;
// string to int
string str="12";
ss<<str;
int a;
ss>>a;
cout<<a<<"\n";
//int to string
ss<<a;
string str1;
ss>>str1;
cout<<str1<<" ";

return 0;
}

No comments:

Post a Comment

Contributors

Translate