I was (quickly) writing some code and accidently inverted the arguments in scanf()
:
char i[] = \"ABC1\\t\";
scanf(i, \"%s\");
Comp
The manual entry for scanf (man scanf) gives the prototype:
int scanf(const char *format, ...);
A char[] is just a special type of char *, so the first argument is satisfied. Secondary arguments are evaluated at runtime (if I recall), so they aren't even considered by the compiler here. From the compiler's prospective, this is a fine call to the function given its prototype.
Also, the compiler never checks whether you are trying to write to invalid locations. The great (or terrible) thing about C is that it will let you do more or less what you want, even if what you want is a bad idea.