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

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.

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.

>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"?

Thanks alot :lol:

I'm sure ill be back

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.