By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,797 Members | 1,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,797 IT Pros & Developers. It's quick & easy.

dos promt staying open when prog runs

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Patio87 wrote:
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.

Jul 22 '05 #2

P: n/a
"Patio87" <pa*****@aol.com> wrote in message
news:20***************************@mb-m21.aol.com...
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
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- e-mail contact form


Jul 22 '05 #3

P: n/a
Ivan Vecerina wrote in news:cf**********@newshispeed.ch in
comp.lang.c++:
"Patio87" <pa*****@aol.com> wrote in message
news:20***************************@mb-m21.aol.com...
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.


#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.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #4

P: n/a
Rolf Magnus wrote:

Patio87 wrote:
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.


Shortcoming? No, (logical!) design.
Jul 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.