#include<stdio.h>
int main()
{
int a,*b,**c,***d,****e;
a=10;
b=&a;
c=&b;
d=&c;
e=&d;
printf("\na=%d b=%u c=%u d=%u e=%u",a,b,c,d,e);
printf("\n%d %d %d %d %d",a,a+*b,**c+***d+****e);
return 0;
}
I could not edit this post… All the options to do so are not visible to my browser.I meant to ask why the compiler didnt warn me and is giving me the output as 0 0 for the extra format specifiers.
What do you expect it to print when given five conversion specifications but only three arguments?
The C standard says, in
7.19.6.1/2In your case, the program happend to print zeroes. In my case, it printed something else.
EDIT in response to the question “why?”: Most compilers do warn about this error:
gcc says
warning: format ‘%d’ expects a matching ‘int’ argumentclang says
warning: more '%' conversions than data argumentsicc says
warning #267: the format string requires additional argumentsHowever, there is no requirement that they must diagnose this. Undefined behavior is just that, undefined. Anything can happen.