Code:
char x[]={'i',' ' ,'l','i','k','e',' ','c','!'};
printf("%s",x);
Result:
i like c!�@i like c!�@
I tried to print char array that not terminated with '\0' and using the string specifier %s in printf.
I expected for error but which didn't happen. Instead the array was printed with some other characters. Why is that?
Passing something other than a (NUL-terminated) string to
%sis undefined behaviour. Anything can happen.