Question:
how to make the window pause in a c++ console application?
2010-07-13 20:03:00 UTC
I know in visual studio you can just hit ctrl+f5 and the cmd prompt will wait for you to press a key before closing, but how do you do that for in the actually .exe, or can you?
Three answers:
????__
2010-07-17 19:03:54 UTC
you can call the .exe from the command prompt of windows, or use some functions like getchar(), cin.get(); and system("pause");
Shadow Wolf
2010-07-14 03:28:07 UTC
Open a console window and run your program from the console window. The window will not close until you close it. This works in Windows or Linux so it is a universal way to run command line programs.



Today's point and click trained people never think about actually running commands manually by typing them in at a command prompt.



You can also make a variety of modifications to your program to force a pause such as asking for another input or waiting for a key press. The actual method can vary a bit depending on which operating system you are using.



Shadow Wolf
Mark J
2010-07-14 03:06:40 UTC
Put a gets() at the end of your routine to wait for a line to be entered.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...