Archived

This topic is now archived and is closed to further replies.

MBC

Problem

Recommended Posts

I have Microsoft Visual C++ 6 and whenever I compile a program and try to open it, it justs opens really quickly and then closes, skipping the part where it says "press any key to continue". I also have a programming book and all the programs on it do the same thing, but when I''m in Visual C++ and I run the program from there it works fine. Does anyone know what''s wrong?

Share this post


Link to post
Share on other sites
<< Does anyone know what''s wrong? >>

Yep, if I understand you, its a common problem. The "press any key to continue" is only seen when the compiled file is run in Visual Studio, its not part of your code. But if you double click the executable outside of Visual Studio it just exits immediately to Windows and you don''t see anything. Right?

What you want to do is add your own "press any key" pause at the end of your program so the window doesn''t close immediately, like a scanf or cin to have it wait for a key press, then you will be able to see your results.

Phil P

Share this post


Link to post
Share on other sites
if PhilVaz is infact understanding you, then try adding getch() at the end of your program (just before the return), the header file for getch() is conio.h, this will keep your program running until a key is pressed.




An ASCII tetris clone... | AsciiRis

Share this post


Link to post
Share on other sites
hey thanks, that was exactly it, I guess I just assumed it to be part of main or something.

Share this post


Link to post
Share on other sites