What if a null character is present in the middle of a string?
问题 I understand that the end of a string is indicated by a null character, but i cannot understand the output of the following code. #include <stdio.h> #include <string.h> int main(void) { char s[] = "Hello\0Hi"; printf("%d %d", strlen(s), sizeof(s)); } OUTPUT: 5 9 If strlen() detects the end of the string at the end of o, then why doesn't sizeof() do the same thing? Even if it doesn't do the same thing, isn't '\0' A null character (i.e, only one character), so shouldn't the answer be 8? 回答1: