stop dos screen in dev C++
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)
Re: stop dos screen in dev C++
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.
Re: stop dos screen in dev C++
http://sourceforge.net/forum/forum.p...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?
Re: stop dos screen in dev C++
Dev C++ examples use that code:
Which uses a non-standard function, and is OS-dependant...
I prefer yours.
Here is a correct implementation:
Code:
#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()
Re: stop dos screen in dev C++
Quote:
Originally Posted by Ajay Vijay
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....