The Little Guy Posted November 29, 2008 Share Posted November 29, 2008 #include <iostream> using namespace std; int main(){ cout << "Game Over!" << endl; return 0; } I am getting the above from a book "Beginning C++ Game Programming 2004". It compiles, but it just doesn't display the command line window, It just closes it. Is there a reason for this? Is it my code, or is it Dev-C++? Link to comment https://forums.phpfreaks.com/topic/134734-c-command-line-window/ Share on other sites More sharing options...
Daniel0 Posted November 29, 2008 Share Posted November 29, 2008 It closes because the program ends. Logical, no? It's doing what you tell it to. You need to either open a console and execute the program from there or you'll need to put something in your program that'll prevent the program from ending. Link to comment https://forums.phpfreaks.com/topic/134734-c-command-line-window/#findComment-701590 Share on other sites More sharing options...
The Little Guy Posted November 29, 2008 Author Share Posted November 29, 2008 So since in the book it only has that code, why does their console window stay open, and mine doesn't? Link to comment https://forums.phpfreaks.com/topic/134734-c-command-line-window/#findComment-701604 Share on other sites More sharing options...
Daniel0 Posted November 29, 2008 Share Posted November 29, 2008 It doesn't. A program closes when it ends. It's always like that. Link to comment https://forums.phpfreaks.com/topic/134734-c-command-line-window/#findComment-701635 Share on other sites More sharing options...
Mchl Posted November 29, 2008 Share Posted November 29, 2008 So since in the book it only has that code, why does their console window stay open, and mine doesn't? Because it's a book... They might just as well forgot this little piece of information, that you should open it in console window Link to comment https://forums.phpfreaks.com/topic/134734-c-command-line-window/#findComment-701637 Share on other sites More sharing options...
DarkWater Posted November 29, 2008 Share Posted November 29, 2008 Add: system("PAUSE"); Right before your return statement. Also, you shouldn't need the std namespace declaration, I'm pretty sure DevC++ (and most compilers) automatically assume that namespace. Link to comment https://forums.phpfreaks.com/topic/134734-c-command-line-window/#findComment-701728 Share on other sites More sharing options...
The Little Guy Posted November 29, 2008 Author Share Posted November 29, 2008 OK, well its good to know, cause I thought I had a bad install of Visual C++, So I tried Dev-C++ and it brought me to this conclusion. Back in 2004, did the window stay open, even after the program ended? btw, what IDE do you guys like? I think I like Visual C++ Express, but I haven't gotten into it much. I like its intellisense, since I don't know any of the functions, methods, classes, and other things that come with C++. I like Dev-C++ because it is much lighter than Visual C++ Express, but it doesn't have the intellisense which I like. Any suggestions? Link to comment https://forums.phpfreaks.com/topic/134734-c-command-line-window/#findComment-701852 Share on other sites More sharing options...
Mchl Posted November 29, 2008 Share Posted November 29, 2008 I would try NetBeans... didn't have oppurtunity to try it with C++ so far... and you have to spend time configuring it. Well. I will do some C++ soon, so I will try it. It works fine for me for PHP, so I suppose it could work as well with C++ Link to comment https://forums.phpfreaks.com/topic/134734-c-command-line-window/#findComment-701853 Share on other sites More sharing options...
Daniel0 Posted November 29, 2008 Share Posted November 29, 2008 Back in 2004, did the window stay open, even after the program ended? Never did, never will, and never was supposed to. Programs end when execution end. If you don't want them to end then you program them to not end. Link to comment https://forums.phpfreaks.com/topic/134734-c-command-line-window/#findComment-701887 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.