Share via


How do I stop "press any key to continue . . ." appearing in a console application?

Question

Friday, May 12, 2006 12:33 AM

I create an empty console project with Visual Studio 2005. I add one source file (Main.cpp) containing the following code:

 

int main (int, char*)

{

 return 0;

}

I produce a release build.

When I run the executable the on Windows Server 2003, the cmd window displays this text that I did NOT program and do NOT want: press any key to continue . . .

How can I get rid of this text?

(I want the cmd window to just disappear when there is nothing in main ()).

 

 

 

All replies (2)

Friday, May 12, 2006 1:18 AM âś…Answered

 aaarrr wrote:

I create an empty console project with Visual Studio 2005. I add one source file (Main.cpp) containing the following code:

 

int main (int, char*)

{

 return 0;

}

I produce a release build.

When I run the executable the on Windows Server 2003, the cmd window displays this text that I did NOT program and do NOT want: press any key to continue . . .

How can I get rid of this text?

(I want the cmd window to just disappear when there is nothing in main ()).

 

It's not part of your program. It's added by Visual Studio when you run it from within Visual Studio using Ctrl-F5 (or equivalent menu shortcut). If you run it with the debugger (using F5), or you run it externally (say by double clicking the exe from Explorer), you won't see this prompt.


Saturday, October 8, 2011 9:54 PM

if you use "conio" library with command of getch();  then you can cmd window appear in your screen.....

 

method:

#include<conio.h>

using namespace std;

void main()

{

getch();

}