![]() |
Integer and String are the two data types in C++ programming languages. An integer is generally used to represent the whole numbers in the number line. A String is a data structure that is used to save a collection of characters. It can be a word or a sentence. Moreover, it can also store the numerical characters representing an integer number. In this article, we are going to learn how to convert an integer to a string in C++. Example: Input: 42(Integer) How to Convert an Integer to a String in C++?To convert an int data type to a string data type, we can use the to_string() function. This function is a part of <string> header. This function is used to convert any data structure to a string. C++ Program to Convert an Integer to a StringC++
Output
Integer to String using to_string(): 42 Time Complexity: O(logN) |
Reffered: https://www.geeksforgeeks.org
C++ |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |