I'am trying to understand a C++ compiler behaviour. Here is a code, where I made two mistakes intentionally:
- forgot
%ld
format specifier inscanf
and just wrote%
. - added unknown format specifer for
printf
- wrote%l
instead of%ld
forlong
datatype.
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
// Complete the code.
int a; long b; char c; float d; double e;
scanf("%d % %c %f %lf", &a, &b, &c, &d, &e);
printf("%d \n%l \n%c \n%f \n%lf", a, b, c, d, e);
return 0;
}
There is a snippet above, that successfully compiles and shows warnings. Why it didn't produce an error for unknown/missing C++ format specifier? How it was compiled?