How does it differ from std::string?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A null-terminated string is a contiguous sequence of characters, the last one of which has the binary bit pattern all zeros. I’m not sure what you mean by a “usual string”, but if you mean
std::string, then astd::stringis not required (until C++11) to be contiguous, and is not required to have a terminator. Also, astd::string‘s string data is always allocated and managed by thestd::stringobject that contains it; for a null-terminated string, there is no such container, and you typically refer to and manage such strings using bare pointers.All of this should really be covered in any decent C++ text book – I recommend getting hold of Accelerated C++, one of the best of them.