| | |
dev-c++ Premature Closing
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2005
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by xinix
Hey all, I posted a question earlier this week regarding dev-c++ and my inability to keep the output window (#include <iostream>) open long enough to see my program running!
I have already tried the following things and would be grateful for any other suggestions!
1:
(Without typing using namespace std\\At the top
std::cout << "Press enter to exit";
std::cin.ignore(std::cin.rdbuf()->in_avail + 1);
return 0;
2:
(Typing using namespace std\\At the top
cout << "Press enter to exit";
cin.ignore(cin.rdbuf()->in_avail + 1)
return 0;
3:
#include <cstdio> \\At the top
cout << "Press enter to exit";
getchar();
return 0;
Someone please help! I seem to have tried everything! If anyone knows dev-c++, could you give me a sure fire way of keeping the output window open! Thank you!
(And thanks to the guys or gals who have already suggest ways to help!)
•
•
Join Date: Feb 2005
Posts: 5
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by xinix
Hey all, I posted a question earlier this week regarding dev-c++ and my inability to keep the output window (#include <iostream>) open long enough to see my program running!
I have already tried the following things and would be grateful for any other suggestions!
1:
(Without typing using namespace std\\At the top
std::cout << "Press enter to exit";
std::cin.ignore(std::cin.rdbuf()->in_avail + 1);
return 0;
2:
(Typing using namespace std\\At the top
cout << "Press enter to exit";
cin.ignore(cin.rdbuf()->in_avail + 1)
return 0;
3:
#include <cstdio> \\At the top
cout << "Press enter to exit";
getchar();
return 0;
Someone please help! I seem to have tried everything! If anyone knows dev-c++, could you give me a sure fire way of keeping the output window open! Thank you!
(And thanks to the guys or gals who have already suggest ways to help!)
Did you try
system("pause");
return 0;
•
•
Join Date: Aug 2008
Posts: 17
Reputation:
Solved Threads: 0
Its simple. Use getch() to hold the screen. You must include the conio.h header file when using getch(). You place it at the end of your code just before the return statement in main().
See below for demo:
See below for demo:
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <conio.h> int main() { cout << "hello world"; getch(); return 0; }
•
•
Join Date: Jan 2008
Posts: 3,835
Reputation:
Solved Threads: 503
This thread is over three years old.
http://www.dreamincode.net/forums/showtopic30581.htm
conio.h is non-standard. cin.get () is standard. See this thread for how to keep the command window open.http://www.dreamincode.net/forums/showtopic30581.htm
![]() |
Other Threads in the C++ Forum
- Previous Thread: Sizeof operator help
- Next Thread: need help with group compiling c/c++ programs
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamic dynamiccharacterarray email encryption error file format forms fstream function functions game givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib library linker list loop looping loops map math matrix memory microsoft newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template templates test text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets




\\At the top

