Menu

#308 Have dos box not "Close on exit" when console app terminates

open
None
9
2012-09-26
2004-09-22
Anonymous
No

Say i have a C program that produces some kind of
output then terminates, i go compile and run (F9), and
the dos box closes immediately after the program
terminates, thus i can't see what the ouput was.

A prompt like "press any key to close" would be good,
like in Visual Studio.

Discussion

  • Anonymous

    Anonymous - 2004-09-27

    Logged In: YES
    user_id=1127202

    Thats not a Dev-C++, but rather a C problem.
    You can get this "press any key to close" by adding
    'system("pause");' of 'getchar(); ( both without the ') at
    the end of your programm, which is exactly what Visual
    Studio does.

     
  • Michal Molhanec

    Michal Molhanec - 2004-09-27

    Logged In: YES
    user_id=828749

    I don't agree with the comment by kaptain_nemo. We don't
    want to pause the app on the end. We only want to see
    console app output. This could be easily implemented using
    e.g. batch file.

     
  • Lennart Borregaard

    Logged In: YES
    user_id=1131858

    Agreed. You should be able to press shift or ctrl plus F9 in
    order to compile and run, but not terminate the program,
    just like in MS Visual Studio.

     
  • Nobody/Anonymous

    Logged In: NO

    I like the feature in lcc-win32. When you use compile->run it
    runs your program and then displays the execution time, return
    code, and then has a pause statement with press any key to
    continue. This way the program pauses to view output and
    you get other important information.

    • Sean
     
  • Max TenEyck Woodbury

    Logged In: YES
    user_id=735003

    This is a defect in the library 'exit', 'abort' or setup
    code. If you want to fix it in the setup code, you need to
    post an 'onexit' callback. In any case, someplace in the
    normal exit sequence you need to do:

    if ( istty( stdin) ) { /* NOT standard but quite
    

    common... /
    puts( "Push any key to exit."); /
    Translate per
    locale? */
    getchar();
    }

    The main problem with this is that it screws up if someone
    does a 'reopen' on stdin and to a lesser extent on stdout.
    That is the main reason for doing something in the setup
    code. If you check before the application has a chance to
    do a 'reopen' and somehow cache handles for stdin and stdout
    for later use, you can ignore what the application does to
    stdin and stdout.

     
  • Nobody/Anonymous

    Logged In: NO

    yes please asap!!!!!!!!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.