Your character array was constructed by the compiler like this:
char s[7] = { 'a', 'b', 'c', 'd', 'e', 'f', '\0' };
The size of s is 7, and it will be fixed. During compile time, your compiler knows this size and you can get it with the operator sizeof.
If you now assign '\0' to s[3], the array looks like this:
char s[7] = { 'a', 'b', 'c', '\0', 'e', 'f', '\0' };
So, the remaining part "def" does not vanish. Instead, 'd' was replaced by '\0', and the following characters are still there.
Since the size of an array is lost after compiling and linking, you need to store it yourself if you want to work with it. Or you need to mark the end of the array with a special value.
This is how the creators of C decided to realize strings. All string function will operate until they find a '\0'.
As an experiment you might like to run this little test:
#include <stdio.h>
int main(void) {
char s[] = "abcdef";
size_t i;
for (i = 0; i < sizeof s; i++) {
if (s[i] != '\0') {
printf("Before s[%zu] = '%c' (0x%02X)\n", i, s[i], s[i]);
} else {
printf("Before s[%zu] = '\\0' (0x%02X)\n", i, s[i]);
}
}
s[3] = '\0';
for (i = 0; i < sizeof s; i++) {
if (s[i] != '\0') {
printf("After s[%zu] = '%c' (0x%02X)\n", i, s[i], s[i]);
} else {
printf("After s[%zu] = '\\0' (0x%02X)\n", i, s[i]);
}
}
}
Oh, and I did not steal your bike. ;-)