Visual Studio Press Any Key to Continue C
- Remove From My Forums
Where is "press any key to continue."?
-
Question
-
I create my program by click File - New - Project from existing code. The program I created does not have "Press any key to continue" at the end to accept the key from keyboard. I want to make my program to have "Press any key to continue" at the end without adding any code. What can I do?
Answers
-
CSH wrote: I create my program by click File - New - Project from existing code. The program I created does not have "Press any key to continue" at the end to accept the key from keyboard. I want to make my program to have "Press any key to continue" at the end without adding any code. What can I do?
Well, this could be one of two questions.
1. If you mean from within VC++ 2005 Express Edition, you can execute the application in a console window using Ctrl+F5. This will create a batch file that executes your program and then presents the message. That is what keeps your console session open long enough for you to see any results from your program.
2. If you mean as a running application, and it is a standard console application, you have two cases:
2.1 Execute the program from within a console session. Use Start | All Programs | Accessories | Command Prompt or a shortcut that you put somewhere for your convenience. (You have to switch to the directory having your program, or add it to the path, or do other things.)
2.2 You can make a batch file in the same directory as your program. The batch file executes your program. Include in the batch file a pause command. If you double-click on the batch file, it will execute the same as if you'd done Ctrl+F5 in VC++ EE.
For example, in my My Projects \hello directory (for Hello World) I just made the file hello.bat that has the following lines in it:
@hello.exe
@pause "Press any Key to Continue ..."And when I double-click on hello.bat from Windows Explorer, I get what you expect. There are more things that can be done. I hope I've given you the basic idea and found the right answer for your actual question
All replies
-
This only happens when you start without debugging (well at least in C# and VB).
-
You can't - if you want your program to do something, you need to write the code to do it. Do you need help with that, or were you just hoping for that in general to happen by itself so you didn't need to write it ?
You could always create a new wizard for a console app that asks for a key press at the end. I personally tend to put a dummy line at the end of my console programs and set a breakpoint, I'd only wrwite a console app to test a theory or to test code I write to post in response to a question, though..
-
Christian,
That's not actually correct. If you start without debugging (Start -> Start without Debugging) on a C++ Console Project, the application will execute and then display 'Press any key to continue'.
-
OK - I guess that change came in after VC6, which is probably the last time I tried it :)
-
CSH wrote: I create my program by click File - New - Project from existing code. The program I created does not have "Press any key to continue" at the end to accept the key from keyboard. I want to make my program to have "Press any key to continue" at the end without adding any code. What can I do?
Well, this could be one of two questions.
1. If you mean from within VC++ 2005 Express Edition, you can execute the application in a console window using Ctrl+F5. This will create a batch file that executes your program and then presents the message. That is what keeps your console session open long enough for you to see any results from your program.
2. If you mean as a running application, and it is a standard console application, you have two cases:
2.1 Execute the program from within a console session. Use Start | All Programs | Accessories | Command Prompt or a shortcut that you put somewhere for your convenience. (You have to switch to the directory having your program, or add it to the path, or do other things.)
2.2 You can make a batch file in the same directory as your program. The batch file executes your program. Include in the batch file a pause command. If you double-click on the batch file, it will execute the same as if you'd done Ctrl+F5 in VC++ EE.
For example, in my My Projects \hello directory (for Hello World) I just made the file hello.bat that has the following lines in it:
@hello.exe
@pause "Press any Key to Continue ..."And when I double-click on hello.bat from Windows Explorer, I get what you expect. There are more things that can be done. I hope I've given you the basic idea and found the right answer for your actual question
Source: https://social.msdn.microsoft.com/Forums/en-US/ba01dc5b-432e-4511-ab7a-08af54191537/where-is-quotpress-any-key-to-continuequot?forum=Vsexpressvc
0 Response to "Visual Studio Press Any Key to Continue C"
Post a Comment