c++ – Is a terminal character stored at the end of string?


Stored there at the end of lines of type string terminal symbol?



Or, at the very least, space has been reserved for it and its meaning has been tampered with. It would be irrational, but it is not forbidden and therefore can take place.

With C ++ 11, this is guaranteed, because the c_str method of std::string must (a) run in constant time and (b) return a pointer directly to the internal buffer of the string object.

This array includes the same sequence of characters that make up the value of the string object plus an additional terminating null-character ('\ 0') at the end.

cplusplus.com, std::string::c_str

Although when working with the std::string (and not its C-compatible piece), the terminal symbol may not play its role , and we can assume that it does not exist.

It is terminal only for algorithms that use this string.

Scroll to Top