I have a simple question.
Why is it necessary to consider the terminating null in an
array of chars (or simply a string) and not in an array of integers. So when i want a
The purpose of null termination in strings is so that the parser knows when to stop iterating through the array of characters.
So, when you use printf with the %s format character, it's essentially doing this:
int i = 0;
while(input[i] != '\0') {
output(input[i]);
i++;
}
This concept is commonly known as a sentinel.