Archived

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

Closing automatically console window

This topic is 5567 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi, I have a console application under windows which always needs a key press when terminated, which is quite annoying. How can I avoid this? Thanks

Share on other sites
Wasn''t there something with GetProcess(...) and KillProcess(...)? Hummm, just look in the MSDN for this...

Share on other sites
One solution is TerminateProcess(). However, you should only use it as a last resort.

Kuphryn

Share on other sites
Thanks
This means there is no "elegant" way of doing it?

Share on other sites
Is it a program you wrote? I''ve never had that happen before. You might want to check the Properties for the program. There might be a "Close window on exit" option.

Share on other sites
Yes I wrote a little Win32 console application and every time I leave the main function with "return 0", the console prints "Press any key to continue" and waits for a key before leaving...

Share on other sites
I would think that only happens when it''s started from the IDE, right?

When I look upon seamen, men of physical science, and philosophers, man is the wisest of all beings. When I look upon priests, prophets, and interpreters of dreams, nothing is so contemptible as man.

Diogenes

Share on other sites
Take out the system("PAUSE";

Try that...

Share on other sites
where i find "system("PAUSE";"

Share on other sites
MSVC console apps do this. There is a way around it but I can''t remember it at the moment. Check google. System("PAUSE" is commonly used with other compilers that don''t make you press a key to exit.

Share on other sites

  vc++ doesn''t use system("PAUSE");

Share on other sites
If you compile the debug version of your program then it adds the system("PAUSE" for you, if you compile for release, it doens''t.

Share on other sites
Mine even stops in release mode.

Share on other sites
it''s not possible in vc++6 sp5

• Forum Statistics

• Total Topics
628658
• Total Posts
2984078

• 10
• 9
• 9
• 10
• 21