I am running the following code snippet:
#include <stdio.h>
int main() {
printf("%f %d\n", 42, 3.14);
}
Which, to my astonishment, displays:
3.140000 42
Compiler (gcc 8.3.0 on a Debian-based distro) does warn me about the order of the arguments:
test.c: In function ‘main’:
test.c:3:13: warning: format ‘%f’ expects argument of type ‘double’, but argument 2 has type ‘int’ [-Wformat=]
printf("%f %d\n", 42, 3.14);
~^ ~~
%d
test.c:3:16: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘double’ [-Wformat=]
printf("%f %d\n", 42, 3.14);
~^ ~~~~
%f
Can a soul more enlightened than mine explain me this behavior? I have found nothing in the specification that would explain it.