Very basic C++ question: running a prog on DevCPP

Associate
Joined
28 Jun 2004
Posts
917
Location
Sheffield
Just decided to start learning a bit of basic C++ and downloaded the DevCPP IDE/Compiler.

Whenever I execute a program, the console pops up for a split second and then disappears again. I can't see anything that's happening and it's very annoying!

How can I make it stay up until I decide to close the console and end the program?

Ta
 
Sounds like you're just writing console apps at the moment, if so try adding...

Code:
getch();

or

std::cin.get();
...to the end of your code, and that will make the console stay around until you hit a key.

cheers
v.f.
 
Ta!

getch(); doesn't work - it says that 'getch' is undeclared
but std::cin.get(); works.

Tis a bit inconvinient to keep writing that at the end of any program I do just so I can see the output though. Isn't there any option in the IDE/compiler itself to do this?

None of the basic programs I'm seeing (eg Hello World etc) have anything like this, so isn't there a better way of doing this?
 
nightwish said:
getch(); doesn't work - it says that 'getch' is undeclared
Think you might be missing an include for that - possibly conio.h

nightwish said:
None of the basic programs I'm seeing (eg Hello World etc) have anything like this, so isn't there a better way of doing this?
A lot of the tutorial type programs assume you are using the command line for compiling (rather than an IDE) so you would see the output from your program on the same console window.

There might well be an option in the IDE, but I'm not familiar with DevCPP unfortunately.

cheers
v.f.
 
Back
Top Bottom