|
-
October 7th, 2005, 09:47 PM
#1
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)
Appreciate others by rating good posts
"Only buy something that you'd be perfectly happy to hold if the market shut down for 10 years." - Warren Buffett
-
October 7th, 2005, 10:54 PM
#2
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.
-
October 8th, 2005, 02:35 AM
#3
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?
-
October 8th, 2005, 03:24 AM
#4
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()
"inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
Club of lovers of the C++ typecasts cute syntax: Only recorded member.
Out of memory happens! Handle it properly!
Say no to g_new()!
-
October 8th, 2005, 08:34 AM
#5
Re: stop dos screen in dev C++
 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....
Appreciate others by rating good posts
"Only buy something that you'd be perfectly happy to hold if the market shut down for 10 years." - Warren Buffett
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|