Click to See Complete Forum and Search --> : stop dos screen in dev C++


sunnypalsingh
October 7th, 2005, 09:47 PM
I have recently started using dev c++ compiler.....my output screen didn't stop.....so i tried mixing old c header(conio.h)...in my code to use getch()...so that my prgram should stop...it did worked...

But is there any other way to stop the screen (instead of mixing old c headers with new ones)

Ajay Vijay
October 7th, 2005, 10:54 PM
I dont see your should have this problem. When you run program without debugging (Ctrl+F5), it stops after returning from main and prints "Press any key to continue." on the console.

On the other side, when you debug the program (F5), you already have control to your process.

a_c
October 8th, 2005, 02:35 AM
http://sourceforge.net/forum/forum.php?thread_id=1347627&forum_id=48211

SOME COMMON PROBLEMS, ANSWERS and HOW-TO's -
(2) How do I keep the display window open so I can see my
results?

SuperKoko
October 8th, 2005, 03:24 AM
Dev C++ examples use that code:

system("PAUSE");

Which uses a non-standard function, and is OS-dependant...
I prefer yours.

Here is a correct implementation:

#include <iostream>


void Wait()
{
std::cout<<"please, enter return to exit!";

std::streambuf *sb=std::cin.rdbuf();
std::size_t BufferSize=sb->in_avail(); // some implementations of in_avail always return 0 :(
while(BufferSize!=0) {sb->sbumpc();--BufferSize;}
sb->sbumpc();
}
int main()
{
std::cin.get(); // fills the internal buffer with a few characters - just to test if it works!
Wait();
return 0;
}


However, it will not work perfectly with VC++ 6.0 nor MinGW for which std::streambuf::in_avail always returns zero. :(
It is a standard implementation of in_avail, like always throwing an exception is a valid implementation of operator new.

In that case, replace the Wait function with std::cin.get()

sunnypalsingh
October 8th, 2005, 08:34 AM
I dont see your should have this problem. When you run program without debugging (Ctrl+F5), it stops after returning from main and prints "Press any key to continue." on the console.

On the other side, when you debug the program (F5), you already have control to your process.

I am talking about dev c++ compiler(version 4.9.9.2)...it compiles through Ctrl+F9 and runs through Ctrl+F10....Ctrl+F5 option is for setting break point......and there is no such message displayed "Press any key to continue"...it just flickers and goes....

Anyways thanxs my problem is solved by other replies....