Yes, per [string.accessors] p1, std::basic_string::c_str()
:
Returns: A pointer
p
such thatp + i == &operator[](i)
for eachi
in[0,size()]
.Complexity: constant time.
Requires: The program shall not alter any of the values stored in the character array.
This means that given a string s
, the pointer returned by s.c_str()
must be the same as the address of the initial character in the string (&s[0]
).