What does the symbol \0 mean in a string-literal?
问题 Consider following code: char str[] = \"Hello\\0\"; What is the length of str array, and with how much 0s it is ending? 回答1: sizeof str is 7 - five bytes for the "Hello" text, plus the explicit NUL terminator, plus the implicit NUL terminator. strlen(str) is 5 - the five "Hello" bytes only. The key here is that the implicit nul terminator is always added - even if the string literal just happens to end with \0 . Of course, strlen just stops at the first \0 - it can't tell the difference.