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

    Question

  • 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 ()).

     

     

     

    Friday, May 12, 2006 12:33 AM

Answers

  •  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.

    Friday, May 12, 2006 1:18 AM

All replies

  •  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.

    Friday, May 12, 2006 1:18 AM
  • 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();

    }

    Saturday, October 08, 2011 9:54 PM