dos promt staying open when prog runs

P

Patio87

I was wondering why when I run a program in my DEV C++ the dos promt doesnt
stay open? it just displays for like a milisecond and exits. Thanks
 
R

Rolf Magnus

Patio87 said:
I was wondering why when I run a program in my DEV C++ the dos promt
doesnt stay open? it just displays for like a milisecond and exits.
Thanks

A shortcoming of Windows. Try opening it yourself and starting your
program from there.
 
I

Ivan Vecerina

Patio87 said:
I was wondering why when I run a program in my DEV C++ the dos promt doesnt
stay open? it just displays for like a milisecond and exits. Thanks
This is the case in several IDEs. If you want to see the output of your
program,
you need to explicitly keep your application open.
Consider adding a statement such as getchar();
or system("pause"); at the end of your program.

hth -Ivan
 
R

Rob Williscroft

Ivan Vecerina wrote in in
comp.lang.c++:
This is the case in several IDEs. If you want to see the output of
your program,
you need to explicitly keep your application open.
Consider adding a statement such as getchar();
or system("pause"); at the end of your program.

#include <iostream>

int main()
{
std::cout << "Press Enter\n";
std::cin.get();
}

Seems to work fine for me :), any old key press won't work though,
you have to hit enter.

Whats really nice is that if I run the above from my editor that
captures the output it doesn't hang (and I don't have to hit enter),
where as the <conio.h>/getch() version does.

Rob.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top