4 ms·
Doesn't C++'s std::string also use a null terminated char* string internally? Do you count that also?
by throwaway2037 10mo ago
Doesn't C++'s std::string also use a null terminated char* string internally? Do you count that also?
- anal_reactor 10mo agoThis doesn't count because it's implemented in a way "if you don't need null-terminated string, you won't see it".
- zabzonk 10mo agoSince C++11 it is required to be null-terminated, you can access the terminator with (for e.g.) operator[], and the string can contain non-terminator null characters.
- masklinn 10mo agoIt has nul-termination for compatibility with C, so you can call c_str and get a C string. With the caveat that an std::string can have nuls anywhere, which breaks C semantics. But C++ does not use that itself.