Strings, or arrays of characters in C must be null terminated to know where they end. Why does the same rule not apply to arrays of other types? eg. How does the computer kn
A string in C is a sequence of char
that is null terminated. It's a special case of a char
array.
You can have a char
array that is not null terminated. For example:
char x[] = { 'a', 'b', 'c' };
Arrays in general are represented as a contiguous sequence of the base type in memory. The language itself doesn't keep track of how big an array is, you're expected to do that yourself.