press any key to continue

This is a discussion on press any key to continue within the C++ Programming forums, part of the General Programming Boards category; How do i disable this in VS2005? i really wanna use my own not the default one...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    610

    press any key to continue

    How do i disable this in VS2005? i really wanna use my own not the default one

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    Huh?
    It's a convenience since console apps are supposed to be run from a command prompt.
    Plus I would disagree on using "your own solution."
    That "press any key..." message is not there in your final EXE anyway, so what does it matter?

    You can also run with debug, and it won't display that message.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    I think the OP wants to use a different message instead of the standard one.

    You can't really do that. In standard C++, the best you could get away with would be to print a message with cout or whatever, and then wait for input. Unfortunately, the user would have to hit enter to continue, not just any key, since C++ input is line-buffered.

    Also see
    http://faq.cprogramming.com/cgi-bin/...&id=1043284385
    http://faq.cprogramming.com/cgi-bin/...&id=1043284385

    For non-standard solutions, see
    http://faq.cprogramming.com/cgi-bin/...&id=1043284392
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    For the heck of it, our own article
    http://apps.sourceforge.net/mediawik...=Pause_console
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    May 2007
    Posts
    27
    You can include <conio.h> in your program. You could then do something like this:

    Code:
    cout<<"Press any key to continue"<<endl;
    _getch();
    Of course you can use whatever message you want in the cout().

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    Conio.h is non-standard, however, and thus should be avoided.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Apr 2008
    Posts
    610

    Angry

    This "press any key ... " can be inconveniencing. On my console app, i have define a box area where inputs are entered ad out puts are shown. This bl##dy press any key just appears at the wrong places and messes up everything

  8. #8
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    Then just run in debug-mode and it will never appear.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by Elysia View Post
    Then just run in debug-mode and it will never appear.
    And when the application runs in real life?

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by csonx_p View Post
    And when the application runs in real life?
    It is not part of your application at all - it is part of the runtime environment that MS Visual Studio creates for your application to run in - it adds the "pause" command to the end of your application OUTSIDE of the application. If you run it from a command prompt window, then you won't see it (because it's not there).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  11. #11
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by matsp View Post
    It is not part of your application at all - it is part of the runtime environment that MS Visual Studio creates for your application to run in - it adds the "pause" command to the end of your application OUTSIDE of the application. If you run it from a command prompt window, then you won't see it (because it's not there).

    --
    Mats
    Oh! and what if i needed it? I mean i'm writing an application assuming that everything which shows now will show as is on the user side .. If i'm hearing you correctly you state that the "press any key.." message wont show when running the exe file ...

  12. #12
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,546
    It will not, simply because command line apps are not supposed to be run from the shell. They are supposed to be run from the cmd, if anything.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  13. #13
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Ok, i've learnt that i could just use getch() instead of system("pause") which causes "press any key ..." .. But both seem not to be a good idea from few ... any ideas as to which function to call instead of the two to pause/halt ?

  14. #14
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by csonx_p View Post
    Ok, i've learnt that i could just use getch() instead of system("pause") which causes "press any key ..." .. But both seem not to be a good idea from few ... any ideas as to which function to call instead of the two to pause/halt ?
    The real question here is "why do you want to do that..."

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  15. #15
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by matsp View Post
    The real question here is "why do you want to do that..."

    --
    Mats
    Working with console applications, sometimes you need to echo something

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 12:48 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 09:00 AM
  3. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM
  4. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21