Advertisement

Question about Dev- C++ compiler

Started by February 25, 2002 12:41 PM
4 comments, last by _Master_2K2_ 22 years, 6 months ago
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.
It''s windows that closes the terminal window once your program quit. Just run command.com and run your program from there.
Advertisement
You could try something like:

system("PAUSE");
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)
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)
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.

This topic is closed to new replies.

Advertisement