17
{
char buf[8];
sprintf(buf,"AAAA%3s","XXXXXXXX");
printf("%s\n",buf);
}
What will happen?
The buffer has 8 characters worth of space and only 3 free characters left, however, "XXXXXXXX" is 8 characters long.
I did a test with Visual Studio 2008 on Windows 7. As a result, the program printed AAAXXXXXXX, and a run-time error happened.