xFactorSchool.com(Beta)
How to Do Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Editor
C Code Editor
C++ Code Editor
C# Code Editor
Java Code Editor
Python Code Editor
HTML Code Editor
CSS Code Editor
JavaScript Code Editor
Practice how to convert integer or double type to string type in C++
C++ Online Editor
Execute Code
More C++ Sample Code
#include <iostream> #include <string> #include <sstream> using namespace std; // use std namespace to avoid std:: before cout int main() { // Convert integer to string int integerVariable = 1225; stringstream intStream; intStream << integerVariable; string convertedIntegerToString = intStream.str();//str() function is used cout << convertedIntegerToString << endl; // Convert string (only numbers) to integer string stringVariable = "1225"; int convertedStringToInteger = stoi(stringVariable);//stoi() function is used to convert string to int cout << convertedStringToInteger << endl; // Convert double to string double decimalVariable = 123.45; stringstream doubleStream; doubleStream << decimalVariable; string convertedDoubleToString = doubleStream.str(); cout << convertedDoubleToString << endl; return 0; }