Thread: How to put a press any key function?

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    6

    Question How to put a press any key function?

    I wanted to use a press any key to continue type of thing in my program, I used getchar(); but that just clears the whole screen and then waits for a key to be pressed...is there any way I can get a press any key function, without clearing the screen?

  2. #2
    Unregistered
    Guest
    Type:

    system("PAUSE");

    just like that where you want it....and it'll say press any key to continue, and when you press any key, the program will end*hope that's what you want*

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    6

    nope..

    Hi thanks for the help...
    I tried that but it didnt work....I am using a unix system...maybe thats the cause....also you said that that will end the program..well, I dont want to end the program...i just want it to wait till the person press any key and then continues with the program when he presses any key.

    How can that be done?

  4. #4
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    522
    I used getchar(); but that just clears the whole screen and then waits for a key to be pressed...
    really... that shouldn't happen post your code so we can see what your doing.
    All spelling mistakes, syntatical errors and stupid comments are intentional.

  5. #5
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    System commands don't work on non-windows systems (at least that's my impression). As for how to do it, you can use getch() or kbhit(). However, these functions are compiler specific. I think they might be in conio.h (which some compilers don't have).

  6. #6
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644

    Re: nope..

    I am using a unix system...maybe thats the cause....
    Yes, that might be why*i'm using a Windows 98*soon to be XP**
    also you said that that will end the program..well, I dont want to end the program...i just want it to wait till the person press any key and then continues with the program when he presses any key.
    sorry, i thought you were looking for it, and it won't close until you press any key.

  7. #7
    Something Clever ginoitalo's Avatar
    Join Date
    Dec 2001
    Posts
    187
    or the classic, but ever popular ....

    char c;
    cin>>c;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  3. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  5. Registery with api?
    By ismael86 in forum Windows Programming
    Replies: 1
    Last Post: 05-14-2002, 10:28 AM