I tried a code today and noticed that printf("%d") still have an output. On my computer I get a output of "1487504216". I would like to know why I gets a output and what the output means. The following is the code I have tried.
#include <stdio.h>
int main()
{
printf("%d");
return 0;
}
printf("%d",...
expects the next parameter to be the number to print. You did not pass it a parameter, so it will just grab the next datum from the stack and will think it is the variable to print. So you read some garbage data and print it...
Formally this is called "undefined behavior" and my explanation can be correct for some compilers and platforms, but other compilers and platforms could intercept the invalid read from the stack and abort your program, or anything else could happen: the behavior is undefined.