Im just learning c++ so ignore my ignorance but when i build up a program and compile it, its ok, but when i try to run it, a black box pops up and goes within a split second. This happens with many dos programs i have run. any ideas?
thx
Im just learning c++ so ignore my ignorance but when i build up a program and compile it, its ok, but when i try to run it, a black box pops up and goes within a split second. This happens with many dos programs i have run. any ideas?
thx
Yeah - check out the FAQ.
What's happening is the computer does everything you ask it to do, and when it's done, it closes the window your program was running in. The way to solve this is to have the computer wait for input at the end of your program. Look for FAQ entries about having your program wait for input.
Thx for the help, i googled "wait for input C++"
And it told me to enter system("PAUSE"); at the end, worked a treat, thx
Okay, now check the FAQ and know that doing so is not recommended.
FAQ > How do I... (Level 1) > Stop my Windows Console from disappearing everytime I run my program?
FAQ > How do I... (Level 1) > How do I get my program to wait for a keypress?
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
You should use std::cin.get() instead of system.
From C to shining C++!
Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
- Bubba
IDE and Compiler - Code::Blocks with MinGW
Operating System - Windows XP Professional x64 Edition
Or just run the program from the command prompt . . . or just read Dave's FAQ links (especially the second one).
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.