Please explain the output of the following program, why the array is printing till 10th array index, if I do not terminate the string with a null character it always print the size of the array and then the loop terminates which means it now found the null character. I checked with different size of array every time I found same result the size at the last and then
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i;
char name[10];
for(i=0;i<10;i++)
{
name[i]='A';
}
for(i=0;name[i]!='\0';i++)
{
printf("%d %d\n",i,name[i]);
}
}
OUTPUT is
0 65
1 65
2 65
3 65
4 65
5 65
6 65
7 65
8 65
9 65
10 10