Is there a null character at end of a std::string?

c++, stdstring, string

Solution

`std::string` is very much a `std::vector`: it has a length attribute and is not zero terminated in C++03; in C++11 'std::string' does seems to be terminated, but I find it easier to think of 'std::string' as a 'std::vector' of characters and not just a terminated buffer.

Problem

We all know there is a null character automatically attached to the end of a C-string. What about a `std::string` object? Is there also a null character at the end of it?

Original source

Related problems