” Press Any Key To Continue C++, Press Any Key To Continue On A New Line

I'm using Dev C++ and every time I open up the app I just compiled it says after my statement, “Press any key to continue.” Besides the fact that there is never a space between the statement and the quote above, which bugs the hell out of me, I can't figure out how to get rid of it.To some of you this may seem a bit trivial, but as I understand it, C++ and coding in general is supposed to do what YOU want, at least most of the time. And, I'd just like to know what I can do to get rid of that in my source file.And if you can tell me how to put a space in between that and my statement, that would be helpful in case that I want that to show up.

Đang xem: Press any key to continue c++

 

#2gabehabe

GabehabeSwamp

*
*
*
*

system (“pause”); causes it to say “press any key to continue. . .”You can get rid of that, and try any number of ways of Holding the Execution Window OpenTry that link, it's pretty helpful and I'm sure will answer all of your questions regarding this matter.Just a quick note, try to avoid the system() function wherever possible. It takes a lot of processing compared to using something more simple such as getch(); or cin.get();Hope this helps

#3Ogre

This does help, thank you.
system(“pause>nul”); this pauses the screen without the little message.But like gabehabe said there are other better ways of pausing the screen. I was taught using the system function though so it's what I'm used to. Gotta get rid of my bad habits…

This post has been edited by tortillaboy05: 06 July 2008 – 12:02 PM

I use system() simply because i know the windows DOS commands very well. Besides, you can't use getch() to XCOPY
Dev C++ I know must have system(“PAUSE”); at the end, but for applications such as Visual Studio, this ending code is unneccesary.
No not at all, I suppose my choice of words for this was a bit poor, I meant to say that in a Visual Studio application it will pause automatically without the system(“pause”); end. Sorry for any confusion I may have caused.

Read more: Camp Bow Wow Duncanville Tx, Camp Bow Wow Duncanville' Live Web Cams

This post has been edited by captainhampton: 08 July 2008 – 05:58 AM

If you run a program from the command line (and it doesn't have system(“PAUSE”); at the end) it will return to cmd after the program is run -> no “Press any key to continue…”.P.S. cin.get(); doesn't work for me. I have no clue why — the compiler seems to ignore it.
And if you can tell me how to put a space in between that and my statement, that would be helpful in case that I want that to show up.

Read more: buy now a hummus and a wow

This program shows you how to put lines after the last statement, so there is one empty line between your statement and “press any key to continue…” in case you ever want to use it.Either use endl without quotes or use \n within quotes. Or you can use both, like so:

#includeusing namespace std;int main(){ //test coutyep that's an entire program, lol. \n is the newline character and if I remember right, endl stands for end line.
We've discussed this topic before out hereIt's a pinned topic for God's sake, how can you miss it?

Leave a Comment