I have an issue in which the size of the string is effected with the presence of a '\0'
character. I searched all over in SO and could not get the answer still.
Here is the snippet.
int main()
{
std::string a = "123123\0shai\0";
std::cout << a.length();
}
The output in this case is
6
Where as the same program with a different string having numerals instead of characters
int main()
{
std::string a = "123123\0123\0";
std::cout << a.length();
}
gives an output of
8
What exactly is happening under the hood? How does presence of a '\0'
character change the behavior?