

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to convert an int to string in C++?
You can use the itoa function from C to convert an int to string.
example
#include<iostream> int main() { int a = 10; char *intStr = itoa(a); string str = string(intStr); cout << str; }
Output
This will give the output −
10
This will convert the integer to a string. In C++11, a new method, to_string was added that can be used for the same purpose. You can use it as follows −
Example
#include<iostream> using namespace std; int main() { int a = 10; string str = to_string(a); cout << str; }
Output
This will give the output −
10
- Related Questions & Answers
- How to convert a Java String to an Int?
- How to convert a String to an int in Java
- Java Program to convert an int value to String
- How to convert int to String in java?
- How to convert int to string in Python?
- Convert String to Java int
- Convert int to String in Java
- How to convert Int to Hex String in Kotlin?
- MongoDB query to convert string to int?
- How to convert a string to int in Lua programming?
- How to convert hex string into int in Python?
- How to convert a String into int in Java?
- How to convert a string into int in C#?
- Java Program to convert a String to int
- Java Program to convert int to binary string
Advertisements