Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

_Master_2K2_

Question about Dev- C++ compiler

This topic is 6015 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m learning to program C++. Because I just spent a lot of money on books, I didn''t want to buy a compiler, so I downloaded Dev- C++ from bloodshed.net. To test it, I entered the code for the ''Hello World'' program. I compiled and ran it, but the program only flashed on screen for a split second, before disappearing. I then coded a simple program, as below: #include <iostream.h> int main () { int i; cout << "Please enter an integer value: "; cin >> i; cout << "The value you entered is " << i; cout << " and its double is " << i*2 << ".\n"; return 0; } I ran the program, and it let me enter an integer value, as it is supposed to. After entering it, the program displayed the text as it should, but then disappeared immediately, not giving me chance to read it. It''s probably a stupid question, but can somebody please tell me what to do to stop this problem, as it is annoying, and an obvious setback when learning C++. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
It''s windows that closes the terminal window once your program quit. Just run command.com and run your program from there.

Share this post


Link to post
Share on other sites
Ha, I had the exactly same problem this morning, and one of the solutions is using the System("pause"); right before the Return 0; but you have to remember to add a #include <stdlib.h> in the begining of the code for it to work. (I''m not shure that''s the right one but I think it is)

Share this post


Link to post
Share on other sites
Ha, I had the exactly same problem this morning, and one of the solutions is, like he said, using the System("pause"); right before the Return 0; but you have to remember to add a #include <stdlib.h> in the begining of the code for it to work. (I''m not shure that''s the right one but I think it is)

Share this post


Link to post
Share on other sites
The code now looks like this:

#include <iostream.h>
#include <stdlib.h>

int main ()
{
int i;
cout << "Please enter an integer value: ";
cin >> i;
cout << "The value you entered is " << i;
cout << " and its double is " << i*2 << ".\n";
system("pause");
return 0;
}

When the program has finished operating, it says ''press any key to continue'', and I have chance to read what it says. Thanks for your help.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!