Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,183 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,381 people online right now. Registration is fast and FREE... Join Now!




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

2 Pages V  1 2 >  
Reply to this topicStart new topic

"...Press any key to continue...", How do I get rid of that?

Ogre
6 Jul, 2008 - 10:17 AM
Post #1

New D.I.C Head
*

Joined: 3 Jul, 2008
Posts: 10


My Contributions
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.

User is offlineProfile CardPM
+Quote Post

gabehabe
RE: "...Press Any Key To Continue..."
6 Jul, 2008 - 10:23 AM
Post #2

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,556



Thanked: 99 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
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 smile.gif
User is online!Profile CardPM
+Quote Post

Ogre
RE: "...Press Any Key To Continue..."
6 Jul, 2008 - 10:30 AM
Post #3

New D.I.C Head
*

Joined: 3 Jul, 2008
Posts: 10


My Contributions
This does help, thank you. smile.gif
User is offlineProfile CardPM
+Quote Post

tortillaboy05
RE: "...Press Any Key To Continue..."
6 Jul, 2008 - 10:59 AM
Post #4

New D.I.C Head
*

Joined: 2 Jul, 2008
Posts: 20


My Contributions
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...sad.gif

This post has been edited by tortillaboy05: 6 Jul, 2008 - 11:02 AM
User is offlineProfile CardPM
+Quote Post

polymath
RE: "...Press Any Key To Continue..."
6 Jul, 2008 - 04:09 PM
Post #5

D.I.C Regular
Group Icon

Joined: 4 Apr, 2008
Posts: 415



Thanked: 4 times
Dream Kudos: 500
My Contributions
I use system() simply because i know the windows DOS commands very well. Besides, you can't use getch() to XCOPY smile.gif
User is offlineProfile CardPM
+Quote Post

Delta_Echo
RE: "...Press Any Key To Continue..."
7 Jul, 2008 - 07:59 PM
Post #6

D.I.C Regular
***

Joined: 24 Oct, 2007
Posts: 439


My Contributions
In a console app, i prefer using cin.get(); to pause the execution.

User is offlineProfile CardPM
+Quote Post

captainhampton
RE: "...Press Any Key To Continue..."
8 Jul, 2008 - 04:38 AM
Post #7

Jawsome++;
Group Icon

Joined: 17 Oct, 2007
Posts: 518



Thanked: 2 times
Dream Kudos: 825
My Contributions
Dev C++ I know must have system("PAUSE"); at the end, but for applications such as Visual Studio, this ending code is unneccesary.
User is offlineProfile CardPM
+Quote Post

gabehabe
RE: "...Press Any Key To Continue..."
8 Jul, 2008 - 04:44 AM
Post #8

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,556



Thanked: 99 times
Dream Kudos: 2650
Expert In: ruling the world.

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

Use something like cin.get();
User is online!Profile CardPM
+Quote Post

captainhampton
RE: "...Press Any Key To Continue..."
8 Jul, 2008 - 04:58 AM
Post #9

Jawsome++;
Group Icon

Joined: 17 Oct, 2007
Posts: 518



Thanked: 2 times
Dream Kudos: 825
My Contributions
QUOTE(gabehabe @ 8 Jul, 2008 - 05:44 AM) *

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: 8 Jul, 2008 - 04:58 AM
User is offlineProfile CardPM
+Quote Post

polymath
RE: "...Press Any Key To Continue..."
8 Jul, 2008 - 08:44 AM
Post #10

D.I.C Regular
Group Icon

Joined: 4 Apr, 2008
Posts: 415



Thanked: 4 times
Dream Kudos: 500
My Contributions
VC++ only displays that message when you choose "run without debugging" inside the IDE run client.
User is offlineProfile CardPM
+Quote Post

lanec42
RE: "...Press Any Key To Continue..."
8 Jul, 2008 - 03:40 PM
Post #11

D.I.C Head
**

Joined: 25 Mar, 2008
Posts: 144


My Contributions
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.

User is offlineProfile CardPM
+Quote Post

OliveOyl3471
RE: "...Press Any Key To Continue..."
8 Jul, 2008 - 06:28 PM
Post #12

It's all about the code ♥
Group Icon

Joined: 11 Jul, 2007
Posts: 1,649



Thanked: 18 times
Dream Kudos: 150
My Contributions
QUOTE(Ogre @ 6 Jul, 2008 - 01:17 PM) *


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:

cpp

#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. wink2.gif
\n is the newline character and if I remember right, endl stands for end line.
User is online!Profile CardPM
+Quote Post

2 Pages V  1 2 >
Reply to this topicStart new topic
Time is now: 12/4/08 11:20AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month