The only complaints I saw of the other proposed ideas was platform dependency and requiring includes. I merely replaced two cons with another. It might be seen as "crashing" the program but it still solves the initial proposed problem.
while(1) (obviously with a corresponding code block) is a common practice when programming devices such as PICs in C. If the program runs off the end of the main function the PIC crashes so there needs to be an infinite loop somewhere. Although, I do recognize the original poster was probably running their code under Windows.
My proposed idea has neither of those cons... or the con that your method is providing. Yours also can't be used to resume the program, incase someone wanted to "pause" the program in a different spot (unless you used something like signal, but then it wouldn't be while(1)).
Holy christ batman, theres a lot of shitty ideas in this thread!
Problem solved.Code:// Stop window from automatically closing std::cin.clear(); std::cin.sync(); std::cin.get();
Why the other ideas are retarded:
while(1) {}
This will cause the program to not return correctly and hence the destructors of local and static objects will never be called.
system("pause");
This is non-portable, 'slow' (compared to the proper alternatives), and just plain stupid.
Last edited by Cypher; 05-28-2009 at 07:38 PM.
Use less comments. Comments should be there to remind you what certain things do incase u set a project aside. Dont comment every line... Just use like:
Code://Death function int death() { blah blah } //Health Regen Function void health regen() { Blah blah }
I like the while(1){} solution, it looks indeed a bit like windows sourcecode
http://www.albinoblacksheep.com/text/source
Last edited by Xarg0; 06-09-2009 at 06:06 AM.
I hacked 127.0.0.1
I use system("PAUSE");
nothing wrong with it lol
Yes there is... if you ever plan to code anything above amateur level then you'll have to stop using kiddy system commands.