0

i'm using Dev C++, and when i write a program, it compiles it fine then when i execute it the program window closes after the program has finished.
does anyone know how to keep the window open. im running on XP(SP2).
i've tried right clicking on the .exe but theres nothing there to stop it closing.

Thanks

3
Contributors
4
Replies
5
Views
13 Years
Discussion Span
Last Post by Calum
0

You can open up a command line prompt and run the program that way, but the more common solution is to ask for input at the end of the program so that a blocking read pauses execution:

#include <iostream>

using namespace std;

int main()
{
  // Your program here

  cin.get(); // Blocking read to pause
}

This generally works unless there's still data left in the input stream, in which case your problem becomes one of flushing the input stream.

0

You can add the following line at the end of you code to see a "press any key to conitinue....." type prompt to the user:

system("pause");


Your program is probably compiled fine its just not staying up after it has executed. U could always run it from the command prompt box.

0

>system("pause");
There must be some "God of the Newbies" who encourages stupid things like this. It's unsafe, nonportable, and slow. Can we say "triple threat"?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.