Quote:Original post by bschneid
Quote:
...I have found out that it is not good programming practice to add unecessary pauses in your programs...
Really, this isn't an unnecessary pause. It makes sense in this situation that you pause the window when its done, doesn't it?
No, it doesn't, because if you're writing a console program, it's with the expectation that your users are going to run it properly, i.e. from a console window - as you should, too.
If you want the convenience of auto-opening a console window and having it stick around at the end of the program run, you can do it with a batch file. Just make a text file, put in two lines - the first being the name of your program, and the second being pause - and change the extension to .bat. (That's for Windows of course; naturally you can do something equivalent on Linux/etc. with any kind of *sh scripting.) Now you have the ability to either pause or not pause your program at the end, and you don't have to recompile two versions each time you change the rest of the code.
Quote:
int main(){ //do program stuff char quit = 'n'; while (quit != 'y') { cout << "Quit the program (y or n)?"; cin >> quit; } return 0;}
This technically isn't an artificial pause, as you are just asking if you want to quit now. If you type y when prompted it will quit.
Exactly - if it makes sense for your program to loop in a way like this, then the program termination is *expected*, and there's no good reason to pause at the end. Adding "boilerplate" artificial-pause-at-end code would just annoy the user. :)