String stream class is used to convert a string into integers, just make a object of string stream class and pass the string which you want to convert into integer. >> Operates is used to read something or some value from the string stream object.
Source Code
#include <iostream> #include <sstream> int main() { using namespace std; cout<<"\t \t \t LEP Tutorials \n \n "; string str = "786"; cout << " Store in String : "<<str <<endl<< endl; stringstream ss(str); int a; ss >> a; cout << " Store in int : "<<a << endl; return 0; }
0 comments:
Post a Comment