- Apr 05, 2012 It's probably not actually in your program. But you're running it from your IDE, and what your IDE does is open up your program in a shell, and then when your program is complete, it does the 'Press any key to continue.
- Press any key to continue C - Developer Community Developer Community for Visual Studio Product family This site uses cookies for analytics, personalized content and ads. By continuing to browse this site, you agree to this use.
Basic C program just bring up 'Press any key to continue.' Hi there, new to C. Below I have wrote the following script on a Windows 7 x64 system using Dev C.
C++ Press Any Key To Exit
I'm VERY inexperienced in programming, I'm just learning the very basics. Anyways, I just figured out how to add a 'pause' line to keep the program from closing as soon as I run it, but now there's a nasty 'Press any key to continue' after my text. Is there a way to hide this? Thanks in advance. :)
- 4 Contributors
- forum 6 Replies
- 3,347 Views
- 1 Day Discussion Span
- commentLatest Postby William HemsworthLatest Post
Narue5,707
I assume you're using
system ( 'PAUSE' )
. My first inclination is to say that this solution is a bad idea anyway, and if it doesn't do exactly what you want, that's all the better for convincing you not to use it. :DThe usual recommendation for pausing a program from an IDE that terminates the hosting console when the program ends is to ask for input. For example, the following code won't terminate until you press the Enter key:
You'll eventually have problems with existing data in the stream causing this not to work, but we have a '>sticky on this forum that teaches you how to deal with that.
I've been looking around the site for an answer to this, only thread i've found pertaining to it was this:
and that thread wasn't very helpful, so, i'm sorry if it's been asked before somewhere.
anyway, onto my question:
The title was pretty self explanatory, I want to know a specific function that I can use to make it so that the user has to press a key before the program continue's running, *AND*, I want to be able to dictate what is said when it asks the user to press any key. So instead of it saying 'Press any key to continue', I can make it say 'Enter a digit' or whatever I want it to say.
Right now I'm using the function System ('PAUSE'), and I'd prefer not to use this.
Dev C++ Press Any Key To Continued
Thanks for any assistance.
- 7 Contributors
- forum 11 Replies
- 300 Views
- 1 Day Discussion Span
- commentLatest Postby WaltPLatest Post
MyrtleTurtle52
There are several ways of doing what you want to do here. I'm sure that I have omitted some, but these will work:
Edited by MyrtleTurtle: n/a