in char arr[8] what is arr[3] whether it will be treated as non string array as they are characters (initializes to zero) or string array.
char arr[8]={'a','b','c'}//what will be arr[3] and onwards \0 or 0.
When you declare an array with an explicit size and initialize it, any members of the array not explicitly initialized are set to 0.
This is specified in section 6.7.9p21 of the C standard:
If there are fewer initializers in a brace-enclosed list than there are elements or members of an aggregate, or fewer characters in a string literal used to initialize an array of known size than there are elements in the array, the remainder of the aggregate shall be initialized implicitly the same as objects that have static storage duration.
So arr[3]
, arr[4]
, arr[5]
, arr[6]
, and arr[7]
will all be 0.
Note also that 0 and '\0'
are two different representations in source code for the same value.