Solution:NIIT/GNIIT Sonugiri0032@gmail.com

Wednesday, January 06, 2016

Integers to string conversion in C++

Integers to string conversion in C++

Structure of the Problem Requirements

String stream class is used to convert an Integers to string. Just make an object of string stream class and pass integers to it.

Source Code

#include <iostream>
#include <sstream>
int main()
{
  using namespace std;
  cout<<"\t \t \t LEP Tutorials \n \n ";
  int num;
  stringstream ss;
  cout<<" Enter a Number : ";
  cin>>num;
  ss<<num;
  string str = ss.str();
  cout<<endl<<endl;
  cout<<"  The Number Converted to String : "<<str<<endl;
  return 0;
}

Output of the Program

Integers to string conversion in C++
Share:

0 comments:

GNIITSOLUTION GNIIT SOLUTION. Powered by Blogger.

Translate

Blog Archive

Unordered List