If we're outputting said array and the first character is \0, is it just ignored and the next character that isn't null treated as the first character?
3 Answers
C-styled strings are by default, sentinel character arrays meaning they terminated at the first appearance of \0 (or some form of null), so it shouldn't be ignored. It should terminate the string, treating it as an empty string.
1 Comment
0 in other types of arrays.By convention, if the "C string" (read char array) uses "string-ish" methods to do something with the string, it will stop at the first ASCII-zero (length parameters are regarded as "up-to" lengths). If it uses "array-ish" methods, it will regard a length parameter as a "precisely" length and iterate a for loop from zero to that size. The latter can often be found in binary handling, while the former is convention for string treatment of char arrays.
Examples in C standard headers are memxyz functions for binary array as opposed to strnxyz functions for strings.
\0? Go to the next character? And what if that is\0? See where this is going? You could never have a string that's empty, or else that print function could wind up in never-never land looking for the first non-NULL character.