string s=“string”;
if(*s.end()==’/0’) cout<<“he”;
he doesnt come.
Doesnt the string store null character in the end?
string s=“string”;
if(*s.end()==’/0’) cout<<“he”;
he doesnt come.
Doesnt the string store null character in the end?
The string you’re using is an object of the string class (called std::string), it is not null-terminated ().
C-style strings on the other hand are null-terminated, they’re basically character arrays terminated with a ‘\0’ ().
For example,
char c[]="string";
assert(c[6]=='\0');
The assert statement will not terminate the program as it evaluates to true.