Is std::string Null-Terminated in C 11?
In 2008, Herb Sutter proposed tightening string implementation in C 0x to require null-termination. However, the C 11 standard includes a different approach:
Yes, std::string is always null-terminated in C 11.
The standard specifies that the pointer returned by std::basic_string::c_str() will be equal to the address of the initial character in the string (&s[0]). Therefore, it is safe to use &str[0] in C 11.
Consequences:
The above is the detailed content of Is std::string Always Null-Terminated in C 11?. For more information, please follow other related articles on the PHP Chinese website!