Convert std::string to C String – c_str)_
The c_str() function is a member function that is used to convert the C++ style string i.e. std::string objects to C style string i.e. array of characters.
Syntax
str1.c_str()
Parameters
- This function does not take any parameter.
Return Value
- Pointer to the equivalent array of characters.
Example
std::string str = "C++"; const char* cstr = str.c_str()
String Functions In C++
A string is referred to as an array of characters. In C++, a stream/sequence of characters is stored in a char array. C++ includes the std::string class that is used to represent strings. It is one of the most fundamental datatypes in C++ and it comes with a huge set of inbuilt functions. In this article, will look at the functions of string computations.
Contact Us