What can happen if printf is called with a wrong format string?

What can happen if printf is called with a wrong format string?

Anything can happen. It is Undefined behavior!
Undefined behavior means that anything can happen. It may show you results which you expect or it may not or it may crash. Anything can happen and you can blame no one but yourself about it.

Reference:

c99 Standard: 7.19.6.1:
para 9:

If a conversion specification is invalid, the behavior is undefined.225) If any argument is
not the correct type for the corresponding coversion specification, the behavior is
undefined.

Leave a Comment