I thought quite a lot about the character string length in c, character string terminates with null character which is '\0', it is not visible in text, as we can see from the c code:
#include <stdio.h>
#include <string.h>
int main(){
char s1[] = "ould";
printf("ould string length is %ld\n", strlen(s1));
char s2[] = {'o','u','l','d','\0'};
printf("ould string length is %ld\n", strlen(s2));
return 0;
}
the book said at the end of section 3.9, s2 is equivalent, but the array size is 5, from the running result, it is 4,from my understanding and search, string ends with '\0', but '\0' will not be included as the string length, but why the author said it is 5? could anyone share ideas or clarity on this??