Connecting Tech Pros Worldwide Help | Site Map

dos promt staying open when prog runs

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 22nd, 2005, 06:00 PM
Patio87
Guest
 
Posts: n/a
Default dos promt staying open when prog runs

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

  #2  
Old July 22nd, 2005, 06:00 PM
Rolf Magnus
Guest
 
Posts: n/a
Default Re: dos promt staying open when prog runs

Patio87 wrote:
[color=blue]
> 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[/color]

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

  #3  
Old July 22nd, 2005, 06:00 PM
Ivan Vecerina
Guest
 
Posts: n/a
Default Re: dos promt staying open when prog runs

"Patio87" <patio87@aol.com> wrote in message
news:20040818034251.15985.00002473@mb-m21.aol.com...[color=blue]
>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[/color]
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




  #4  
Old July 22nd, 2005, 06:00 PM
Rob Williscroft
Guest
 
Posts: n/a
Default Re: dos promt staying open when prog runs

Ivan Vecerina wrote in news:cfv7ns$j4m$1@newshispeed.ch in
comp.lang.c++:
[color=blue]
> "Patio87" <patio87@aol.com> wrote in message
> news:20040818034251.15985.00002473@mb-m21.aol.com...[color=green]
>>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[/color]
> 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.
>[/color]

#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/
  #5  
Old July 22nd, 2005, 06:01 PM
Julie
Guest
 
Posts: n/a
Default Re: dos promt staying open when prog runs

Rolf Magnus wrote:[color=blue]
>
> Patio87 wrote:
>[color=green]
> > 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[/color]
>
> A shortcoming of Windows. Try opening it yourself and starting your
> program from there.[/color]

Shortcoming? No, (logical!) design.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.