once I declared char array[10]; does the last subscript contains '\0' ?
The answer is NO: when you define the array as an automatic variable (a local variable in a function), it is uninitialized. Hence none of its elements can be assumed to have any specific value. If you initialize the array, even partially, all elements will be initialized, either explicitly from the values provided in the initializer or implicitly to 0 if there are not enough initializers.
0 and '\0' are equivalent, they are int constants representing the value 0. It is idiomatic to use '\0' to represent the null byte at the end of a char array that makes it a C string. Note that '0' is a different thing: it is the character code for the 0 digit. In ASCII, '0' has the value 48 (or 0x30), but some ancient computers used to use different encodings where '0' had a different value. The C standard mandates that the codes for all 10 digits from 0 to 9 must be consecutive, so the digit n has the code '0' + n.
Note that the loop in your code sets the value of 9 elements of the array to non zero values, and leaves the last entry uninitialized so the array is not null terminated, hence it is not a C string.
If you want to use the char array as a C string, you must null terminate it by setting array[9] to '\0'.
Note also that you can print a char array that is not null terminated by specifying the maximum number of bytes to output as a precision field in the conversion specifier: %.9s.
Finally, be aware that array[0] = 1; does not set a valid character in the first position of array, but a control code that might not be printable. array[0] = '0' + 1; set the character '1'.
#include <stdio.h>
int main(void) {
char array[10];
/* use the element number as the loop index: less error prone */
for (int i = 0; i < 9; ++i) {
array[i] = `0` + i + 1;
}
// array[] contains numbers from 1 to 9 and an unitialized subscript
printf("%.9s\n", array); // prints up to 9 bytes from `array`
array[9] = '\0';
// array[] contains numbers from 1 to 9 and a null terminator, a valid C string
printf("%s\n", array); // produce the same output.
return 0;
}