How to convert a single character to a string object.
Input : x = 'a' Output : string s = "a" Input : x = 'b' Output : string s = "b"
The idea is to use string class which has a constructor that allows us to specify size of
string as first parameter and character to be filled in given size as second parameter.
// Create a string of size n and fill // the string with character x. string s(int n, char x);
- Convert string to char array in C++
- Substring in C++
- std::to_string in C++
- std::find in C++
- std::string::append() in C++
- Split numeric, alphabetic and special symbols from a String
- 5 Different methods to find length of a string in C++
- std::string class in C++
- Converting string to number and vice-versa in C++
- Converting Strings to Numbers in C/C++
- Different methods to reverse a string in C/C++
- std::sort() in C++ STL
- C++ string class and its applications
- Vector in C++ STL
- Set in C++ Standard Template Library (STL)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.