std::basic_string<CharT,Traits,Allocator>::c_str (3) - Linux Man Pages
const CharT* c_str() const; (until C++11)
const CharT* c_str() const noexcept; (since C++11)
Returns a pointer to a null-terminated character array with data equivalent to those stored in the string.
The pointer is such that the range [c_str(); c_str() + size()] is valid and the values in it correspond to the values stored in the string with an additional null character after the last position.
The pointer obtained from c_str() may be invalidated by:
* Passing a non-const reference to the string to any standard library function, or
* Calling non-const member functions on the string, excluding operator, at(), front(), back(), begin(), rbegin(), end() and rend().
Writing to the character array accessed through c_str() is undefined behavior.
c_str() and data() perform the same function. (since C++11)
Pointer to the underlying character storage.
c_str()[i] == operator(i) for every i in [0, size()). (until C++11)
c_str() + i == std::addressof(operator(i)) for every i in [0, size()]. (since C++11)
The pointer obtained from c_str() may only be treated as a pointer to a null-terminated character string if the string object does not contain other null characters.
// Run this code
front accesses the first character
back accesses the last character
data (public member function)