Skip to main content
gamedev.net
🔒 Locked

Try my program

Started by PnP Bios Nov 21, 2004 at 5:27 PM 8 replies 550+ views
Original Post
PnP Bios
PnP Bios
#include int main(void) { static int i = 0; ++i; printf("pfft. %i.\n", i); return main(); } does it actually compile and run? or does it crash and burn? Tested on vs6. goes to about 12316 iterations then craps out.
benryves
benryves
As PnP knows, on VC++.NET 2003 it goes on pretty much forever when compiled with the "Release" settings, but gets to about 5000 in debug mode.
[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]
Zul
Zul
I don't want to piss my machine off today, so I think I'll not.
oh hai
Coward
Coward
Quick question.

Even though it's a static function, won't the int allocated again, using the same values as from the last "layer" of main?

If so it would be pretty muc limited by memory, right?
Don't Temp Fate..
ontheheap
ontheheap
2 5 million and counting
PnP Bios
PnP Bios
Quote:
Original post by Coward
Quick question.

Even though it's a static function, won't the int allocated again, using the same values as from the last "layer" of main?

If so it would be pretty muc limited by memory, right?

all it does is keep a running count of where it is in the program. so, if say, you wanted to break out after 500, you would just have to test for 500.

Oh, and please state which compiler you are using.
ontheheap
ontheheap
Quote:
Original post by ontheheap
2 5 million and counting


g++ (GCC) 3.3.4
Hedos
Hedos
64 000 000 and still going..
Microsoft Visual C++ .NET 2003
Release mode compilation
choffstein
choffstein
used dev-c++ version 5 beta...which means g++ version...god, I dont know. im at about 11.5 million right now though. still going strong.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.