odbapsvm wrote:
> Does anyone know what happens if you call
> main from main and end up with an infinite loop?
>
> void main(void) {
>
> void main();
> }
>
> Will you exhaust memory, crash the machine or
> neither.
>
> I know that nothing would be more educational than
> trying it, but I thought that doing this might
> be somewhat dangerous.
>
> Thanks
>
> Nick
What is the deal with people putting void, int, whatever in front of the
function call?
int main()
{
main();
}
To answer the question: Assuming it even compiles in the first place
(C++ = no, C = yes), each function call would put the return address on
the stack on most platforms. The stack is a limited resource. The
program would crash with a "stack overflow error" once it attempted to
go past the limit of the stack. IIRC, under Windows, the default size
of the stack is 1MB, which is more than sufficient for a well-written
program.
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/