basic_string::c_str
const charT* c_str() const;
const charT* c_str() const noexcept;
Get C-string equivalent
This array includes the same sequence of characters that make up the value of the basic_string object plus an additional terminating null-character (
charT()) at the end.
A program shall not alter any of the characters in this sequence.
The pointer returned points to the internal array currently used by the basic_string object to store the characters that conform its value.
Both basic_string::data and
basic_string::c_str are synonyms and return the same value.
The pointer returned may be invalidated by further calls to other member functions that modify the object.
Parameters
noneReturn Value
A pointer to the c-string representation of the basic_string object's value.charT is basic_string's character type (i.e., its first template parameter).Example
|
|
Output:
Please split this sentence into tokens
Complexity, iterator, access, exceptions
Unspecified or contradictory specifications.
Complexity
Constant.Iterator validity
No changes.Data races
The object is accessed.Exception safety
No-throw guarantee: this member function never throws exceptions.See also
- basic_string::data
- Get string data (public member function)
- basic_string::copy
- Copy sequence of characters from string (public member function)
- basic_string::operator[]
- Get character of string (public member function)
- basic_string::front
- Access first character (public member function)