Integers to String Conversion in C++

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 on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment