The code behaves correctly. Indeed, scanf declared
int scanf(const char *format, ...);
Fortunately, your format does not contain % , for which there would be no match in ... that would invoke UB.
In addition, format is a string literal that allows the compiler to go through it, ensuring that you pass the correct type of parameters with respect to format specifiers, since some health checks are included with higher levels of warnings. (-Wformat-family)
source share