printf insufficient arguments
My question is about the behavior after a printf with a missing argument:
printf("%s blah blah %d", int); // integer was given as argument (and not int written)
I already know that if there are insufficient arguments for the format, the behavior is undefined.
The question is whether it is undefined for the printf outcome or for the whole program?
- A crash can happen when %s tried to read from unauthorized memory address. (it happened to me)
- Can a crash happen [long] after the printf complete? (printed some garbage string and an integer)
Edit:
To clarify I'm not asking about compilation errors or warnings, nor can a program crash when executing this line. The question is can this line make the program crash randomly after this line already executed.
Solution 1:
It is undefined for the whole program.
In fact it is undefined before even the program exists: it is undefined what the compiler itself does in presence of the text printf("%s blah blah %d", int);