The following program gives an unexpected output .
#include<stdio.h>
int main()
{
int a=10,b=20;
printf("a=%d",a);
printf(" b=%d");
printf(" %d");
return 0;
}
Why does the above code print: a=10 b=10 10
The output is same even if I declare b before a, or make 'a' register variable.
According to this post - Behaviour of printf when printing a %d without supplying variable name, a random value from the current stack is printed. But if that was the case, then changing the declaretion styles would result in different results.
So, what is actually happening here?