Solution:NIIT/GNIIT Sonugiri0032@gmail.com

Wednesday, January 06, 2016

String to int conversion in C++

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:

0 comments:

GNIITSOLUTION GNIIT SOLUTION. Powered by Blogger.

Translate

Blog Archive

Unordered List