Basically strlen
iterate the string until he found a null-character:
strlen implementation
int strlen(const char *str) {
int i = 0;
while (str[i] != '\0') {
i++;
}
return i;
}
So this is why "dog\0\0\0" length is 3 and not 6