Q:

Why printf(char[]) generates a warning, meanwhile printf("asdf") doesn't

Possible Duplicate:
warning: format not a string literal and no format arguments 

I have very simple question: Why when I make char[] s = "hi"; printf(s) it issues a warning: "warning: format not a string literal and no format arguments", meanwhile printf("aa") doesn't. 
I've already read a difference between char array and string literal (one is const char const* and another is char*), but from printf() signature: 
http://www.gnu.org/software/libc/manual/html_node/Formatted-Output-Functions.html#Formatted-Output-Functions 
I see that it's suitable for any of that types. So my question is why printf("aaa") don't issue any warnings (does it somehow checks that literal is a const, meanwhile array isn't)?

A:

The GNU compiler and a lot of other compilers these days do indeed check the format strings for the printf-family against the arguments supplied.  The compiler is warning that it cannot do this for non-literal strings.
Using a non-literal format string is considered to be a bad practice.  Using a format string that you do not control is much worse.

A:

The reason for this is that there were a bunch of security issues around 10-15 years ago caused by people assuming that it was safe to call printf(s) where "s" had user supplied input. Many compilers added warnings for this to avoid the issues. If you want to just print out a string, use puts() instead. If you're not absolutely certain that the string you're sending into printf doesn't contain '%' characters, you should use printf("%s", s);

