|
-
October 15th, 2010, 12:26 PM
#10
Re: Beginner's use of system("pause");
monarch_dodra, I think you're right in that any stream-based pause function would have more or less the same specific weaknesses. To get around this, I think of using the conio functions, but I'm afraid they're most probably specific to Windows or even MS VC++.
For overcoming the necessity of calling pause() at the end of main() I think of making some kind of reverse-RAII pause class that does the pause on destruction and instantiate it as a global object. But even then there's no way to control whether it would actually get destroyed as the last one of the global objects. I better don't start to think about C++ runtime manipulations... But couldn't it be a surprisingly simple solution to just wrap the toy program into another one that does nothing more than exec...() the toy and then pause? The only problem then would be to have the IDE use that.
In the end, simply using a separate console window might be the best solution. (Don't remember right now who suggested that.)
And BTW, at least under Win XP a malicious pause program wouldn't have a chance: The pause command there is hardcoded inside the shell and always has priority over any program with the same name.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|