Notice that no terminating null character is appended (see member c_str for such a functionality).
The returned array points to an internal location which should not be modified directly in the program. Its contents are guaranteed to remain unchanged only until the next call to a non-constant member function of the string object.
Parameters
noneReturn Value
Pointer to an internal array containing the same content as the string.Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
Output:
str and cstr have the same length. str and cstr have the same content. |
Basic template member declaration
( basic_string<charT,traits,Allocator> ) |
See also
| string::copy | Copy sequence of characters from string (public member function) |
| string::c_str | Get C string equivalent (public member function) |
| string::assign | Assign content to string (public member function) |
