Showing posts with label string conversion in integer C. Show all posts
Showing posts with label string conversion in integer C. Show all posts

Thursday, 5 February 2015

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++