dos promt staying open when prog runs

Discussion in 'C++' started by Patio87, Aug 18, 2004.

  1. Patio87

    Patio87 Guest

    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
    Patio87, Aug 18, 2004
    #1
    1. Advertising

  2. Patio87

    Rolf Magnus Guest

    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.
    Rolf Magnus, Aug 18, 2004
    #2
    1. Advertising

  3. "Patio87" <> wrote in message
    news:...
    >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
    Ivan Vecerina, Aug 18, 2004
    #3
  4. Ivan Vecerina wrote in news:cfv7ns$j4m$ in
    comp.lang.c++:

    > "Patio87" <> wrote in message
    > news:...
    >>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/
    Rob Williscroft, Aug 18, 2004
    #4
  5. Patio87

    Julie Guest

    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.
    Julie, Aug 18, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QWRhbQ==?=

    ASP.NET 2.0 - Sleeping connections staying open

    =?Utf-8?B?QWRhbQ==?=, Aug 15, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    587
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Aug 15, 2006
  2. -intl.com
    Replies:
    1
    Views:
    359
    Martin Gregorie
    Oct 22, 2006
  3. shanti bhushan

    subprocess in Command promt+ webbrowser

    shanti bhushan, Jun 19, 2010, in forum: Python
    Replies:
    2
    Views:
    454
    shanti bhushan
    Jun 19, 2010
  4. shanti bhushan

    start and kill process by command promt

    shanti bhushan, Jun 21, 2010, in forum: Python
    Replies:
    2
    Views:
    768
    Giampaolo RodolĂ 
    Jun 21, 2010
  5. Shyam Prakash

    Hiding cmd promt window

    Shyam Prakash, Feb 3, 2005, in forum: ASP .Net Security
    Replies:
    2
    Views:
    168
    Shyam Prakash
    Feb 4, 2005
Loading...

Share This Page