\0 in c++
'\0' :
is the NULL character, you can find it in your ASCII table ,
it has the value 0. It is used to determinate the end of C-style strings.
However, C++ class std::string stores its size as an integer, and thus
does not rely on it.
\0 in c++
'\0' :
is the NULL character, you can find it in your ASCII table ,
it has the value 0. It is used to determinate the end of C-style strings.
However, C++ class std::string stores its size as an integer, and thus
does not rely on it.
\0 in c++
C++ std::strings are "counted" strings - i.e., their length is stored as an integer, and they can contain any character. When you replace the third character with a \0 nothing special happens - it's printed as if it was any other character (in particular, your console simply ignores it).
In the last line, instead, you are printing a C string, whose end is determined by the first \0 that is found. In such a case, cout goes on printing characters until it finds a \0, which, in your case, is after the third h.
\0 is the NULL character, you can find it in your ASCII table , it has the value 0. It is used to determinate the end of C-style strings. However, C++ class std::string stores its size as an integer, and thus does not rely on it
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us