"...Press any key to continue..."

How do I get rid of that?

Page 1 of 1

13 Replies - 8600 Views - Last Post: 09 July 2008 - 01:49 AM Rate Topic: -----

#1 Ogre  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 03-July 08

"...Press any key to continue..."

Posted 06 July 2008 - 11:17 AM

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.

Is This A Good Question/Topic? 0
  • +

Replies To: "...Press any key to continue..."

#2 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1383
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: "...Press any key to continue..."

Posted 06 July 2008 - 11:23 AM

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 Open

Try 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 :)
Was This Post Helpful? 0
  • +
  • -

#3 Ogre  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 03-July 08

Re: "...Press any key to continue..."

Posted 06 July 2008 - 11:30 AM

This does help, thank you. :)
Was This Post Helpful? 0
  • +
  • -

#4 tortillaboy05  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 02-July 08

Re: "...Press any key to continue..."

Posted 06 July 2008 - 11:59 AM

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

Was This Post Helpful? 0
  • +
  • -

#5 polymath  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 52
  • View blog
  • Posts: 670
  • Joined: 04-April 08

Re: "...Press any key to continue..."

Posted 06 July 2008 - 05:09 PM

I use system() simply because i know the windows DOS commands very well. Besides, you can't use getch() to XCOPY :)
Was This Post Helpful? 0
  • +
  • -

#6 Delta_Echo  Icon User is offline

  • D.I.C Addict

Reputation: 5
  • View blog
  • Posts: 722
  • Joined: 24-October 07

Re: "...Press any key to continue..."

Posted 07 July 2008 - 08:59 PM

In a console app, i prefer using cin.get(); to pause the execution.
Was This Post Helpful? 0
  • +
  • -

#7 captainhampton  Icon User is offline

  • Jawsome++;
  • member icon

Reputation: 13
  • View blog
  • Posts: 548
  • Joined: 17-October 07

Re: "...Press any key to continue..."

Posted 08 July 2008 - 05:38 AM

Dev C++ I know must have system("PAUSE"); at the end, but for applications such as Visual Studio, this ending code is unneccesary.
Was This Post Helpful? 0
  • +
  • -

#8 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1383
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: "...Press any key to continue..."

Posted 08 July 2008 - 05:44 AM

Dev-CPP doesn't have to have system ("pause");

Use something like cin.get();
Was This Post Helpful? 0
  • +
  • -

#9 captainhampton  Icon User is offline

  • Jawsome++;
  • member icon

Reputation: 13
  • View blog
  • Posts: 548
  • Joined: 17-October 07

Re: "...Press any key to continue..."

Posted 08 July 2008 - 05:58 AM

View Postgabehabe, on 8 Jul, 2008 - 05:44 AM, said:

Dev-CPP doesn't have to have system ("pause");

Use something like cin.get();


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.

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

Was This Post Helpful? 0
  • +
  • -

#10 polymath  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 52
  • View blog
  • Posts: 670
  • Joined: 04-April 08

Re: "...Press any key to continue..."

Posted 08 July 2008 - 09:44 AM

VC++ only displays that message when you choose "run without debugging" inside the IDE run client.
Was This Post Helpful? 0
  • +
  • -

#11 lanec42  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 229
  • Joined: 26-March 08

Re: "...Press any key to continue..."

Posted 08 July 2008 - 04:40 PM

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.
Was This Post Helpful? 0
  • +
  • -

#12 OliveOyl3471  Icon User is offline

  • Everybody's crazy but me!
  • member icon

Reputation: 134
  • View blog
  • Posts: 6,581
  • Joined: 11-July 07

Re: "...Press any key to continue..."

Posted 08 July 2008 - 07:28 PM

View PostOgre, on 6 Jul, 2008 - 01:17 PM, said:

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.


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:

#include<iostream>

using namespace std;

int main()
{  
   //test
   cout<<"Welcome to the game.\n"<<endl;
    system("Pause");
    return 0;  
    }



yep that's an entire program, lol. ;)
\n is the newline character and if I remember right, endl stands for end line.
Was This Post Helpful? 0
  • +
  • -

#13 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: "...Press any key to continue..."

Posted 08 July 2008 - 11:20 PM

We've discussed this topic before out here

It's a pinned topic for God's sake, how can you miss it? ;)
Was This Post Helpful? 0
  • +
  • -

#14 paramore18  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 30-June 08

Re: "...Press any key to continue..."

Posted 09 July 2008 - 01:49 AM

get rid of sytem("Pause");

try ur getch();
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1