Using Dev-cpp, a small program compiles but the resultant .exe file
does not run. From the DOS command, it runs. When I try from the
windows run command , it flashes but immediately goes away.

Using Dev-cpp, a small program compiles but the resultant .exe file
does not run. From the DOS command, it runs. When I try from the
windows run command , it flashes but immediately goes away.

try ./filename

cin.ignore(); // this ignores one enter key

or

system("pause"); 
// should use cin.ignore but you can use this
// it displays: "Press any key to continue..."
// and when you press any key, it continues...

or as veron was saying

// Before using this make sure you have included: #include <windows.h>
Sleep(1000);
// the amount you put is in miliseconds, 1000 = 1 second
// this will wait the amount of time you put into before moving on.

put that in, and you will press enter before the window closes..

atm it is running correctly but it doesent know you want it to wait till you want to end it, so you have to add that.

Small programs usually run in command prompt...if you want it to have its own window, that's a different matter.

cin.ignore(cin.rd_buf()->in_avail());
cin.get();

Slap that on the end of the code. This will do the following:
ignore all the available input from the cin (console) input buffer, then grabs a null terminated character (basically waits until you hit enter).

Comments
Elegant use of ignore+buffer I hadn't seen before.
This article has been dead for over six months. Start a new discussion instead.