Re: What will happen if main called in side main function?



Eric Sosman wrote:

Ravi wrote On 03/31/06 12:03,:

<snip>

int main()
{
main();
}

This example will execute forever, provided the machine
running it has infinite resources. Less powerful machines
may be unable to run this program to completion ...

A slightly better implementation without infinite resources might use tail recursion optimisation and convert it in to a simple loop that only terminates when the machine itself is terminated.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
.