Why does calling main()
inside the body of main()
cause an finite loop?
#include<stdio.h>
int main()
{
printf("\n Sonata Software");
main();
return 0;
}
Why does calling main()
inside the body of main()
cause an finite loop?
#include<stdio.h>
int main()
{
printf("\n Sonata Software");
main();
return 0;
}
This "loop" terminates or is "finite" because you keep calling main()
from within main()
, eventually using up all the stack frame space you have and resulting in a StackOverflow
This program will not run. Main is not a userdefined function, that you'll call it as function within main as recursion. It'll show some error.