You told printf() how to print something (the format specifier %d), but you did not tell printf()what to print.
To elaborate, you forgot to supply the required argument for the supplied format specifier %d.
C standard says, if there are insufficient argument for supplied format specifier, the behaviour is undefined.
FWIW, just specifying the format specifier won't magically consider the argument for it. You need to write something like
printf("%d", x);
to print the value of x.
1
Gopi
On
The printf() has the below prototype
int printf(const char *,...);
What you pass is %d to the printf() and since this is a format specifier to print out intprintf() looks for the parameter which needs to be printed out since you don't pass any this is undefined behavior
You told
printf()
how to print something (the format specifier%d
), but you did not tellprintf()
what to print.To elaborate, you forgot to supply the required argument for the supplied format specifier
%d
.C
standard says, if there are insufficient argument for supplied format specifier, the behaviour is undefined.FWIW, just specifying the format specifier won't magically consider the argument for it. You need to write something like
to print the value of
x
.