Output Says Press any key to continue.

Hello all!

I have a problem where I enter my first statement in the output, it works but after that, the output says press any key to continue and the outputs closes... I want to get rid of that so I will be able to enter my second statement. If there is any way to fix it, I would be glad to be helped!

Thank you.
It would be helpful if you could post your code here so everyone who stops by could analyze the problem.

I'm a beginner myself and looking at the whole code is great way to spot the errors.
Last edited on
that is the standard output from the windows (dos) console command "pause" which is routinely invoked in c++ code as system("pause"); ... look for that statement and eliminate it if you don't want it there. It is used to stop the program to see output, mostly, and removal will not harm most programs.

the reason is that cin>> bogus requires pressing enter key, or more than 1 key, ... the any-key press is not available in c++ easily so they use the built-in OS command for it.

the output closes issue is resolve ... by adding system("pause") to the very end of your program, the last statement in main. If you don't want the 'press any key' text, you can do a cin statement or if you pull in the old dos libraries you can use getch() or something at the end to pause the program to see output. OR you can just run the executable program from a console that you opened, instead of letting it open its own console. That requires rudimentary dos/console skills, which I HIGHLY recommend you learn at some point.

you can do that with start/run/cmd and inside the program cd \ (go to root c:\ ) and then cd foldername1 ... until you arrive where your executable is then just executablename to run it.

Last edited on
Registered users can post here. Sign in or register to post.