Consider the case:
char s1[] = "abc";
s1[3] = 'x';
printf("%s", s1);
As I know, printf
prints characters until it finds the null character and then stops.
When I overwrite the null character by 'x'
, why does printf
print the s1
array correctly? How does it find the null character?