GP32 Stupid Question


Efompor

Premium Member
Joined
Feb 5, 2004
Messages
377
Age
118
Location
USA, Maryland
Website
Visit site
yeah I know this is a dumb question, but I have no experiance with DOS on windows XP. I am using Dev C++ by bloodshed software and I am trying to do this C++ tutorial. Yeah. And every time I run the compiled code on the dos prompt, the freaking program auto closes before I can see it! How do I tell dos not to close on exit every time I run the code? It's supposed to close when it's done, but I see it as nothing but a hassle. Actually it closes so fast now that I cant see it at ALL. The screen just flickers for a millisecond. I am a complete beginner to C++, the only thing I can program on is my graphing calculator :huh:
 
yeah I'm opening it from within the compiler by pressing "Run". The dos window flashes up with my executed code and then closes before I can look at it
 
Start->Run, type in "cmd", press "ok", cd to the dir you prog is in, type in the exe name, and you should see the output there.
 
Are you using a bat file?

If s you can just write

Code:
pause

at the end of the bat file
 
Yeh Im having the exact same problem and Im using the same compiler. When I tried to view my first program Hello World it just flashed up and off in an instant. You could only just about make out Hello World had been written but I had to check a few times cos it was so quick!
This is happening with C++ and Im using windows 98 SE. There must be a way to stop this and keep that DOS screen up.

I did look in Sams teach yourself C++ in 21 days and it does say near the beggining chapters as one of the notes what you can do to relieve this problem. I didnt manage to get two of them working cos cudnt find what I needed on the compiler I was using. They did on the other hand say to write a particular bit of code in (just a line or two) and that would stop the screen from flashing.
I havent tried this yet as my monitor wont stay on when I switch it on (its an old monitor) but if you look in that book and get that code then I think that should work.

Even though that is a solution I would still like to know how to make the screen stay on with writing code for it, as this is what it should do, so if anyone can help Id be greatful?
 
Answers already been given... Run the prog from a DOS prompt otherwise you'll not see anything...
 
This was bugging me for ages, but I came up with an (inelegant) workaround.

At the end of your "main" function (i.e. just before you type "return 0"):

int z; // declare a variable called z
cin >> z; // tells the program to wait for the user to enter a value for z.

The program will pause until you enter a value for z, allowing you to read whatever is written in the window that flashes up. When you've finished reading, enter a value (i.e. press pretty much any key then enter). The program will then continue to the next line, which should be the "return 0;" statement, ending the program and closing the window.

Hope this helps... it's not a pretty way to do it, but it's good enough while I'm learning :). I'm on Sam's 21 days thing as well, with the same environment as you guys. So far I'm up to introducing the simple classes... or something :blink:.

Have fun,
Melville
 
Back
Top