The following code gives output as 0 0 0 0 using Codeblocks.
int main()
{
static int i=5;
if(--i){
main();
printf("%d ",i);
}
}
I perfectly understands how the above code executes. However, when I removed 'static' from the code and used int i = 5, Ideone.com(online compiler) gave me runtime error and Codeblocks(using GCC) gave me nothing- even the terminal does not pop up.
I also tried placing the declaration part outside main i.e., static int i; and in main, I then gave i = 5;. Still, I am getting the above errors. I have no idea what is happening. Any help would be greatly appreciated.
PS: The program was found on a website and no explanation was given there.