Thursday, 5 February 2015

String to int conversion in C++

Structure of the Problem Requirements 

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;

Output of the Program

String to int conversion in C++

Share it Please

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.


Post a Comment