Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: KeyPress in C

  1. #1
    New Coder
    Join Date
    Nov 2003
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    KeyPress in C

    how do I get it so when the user presses a character, it performs a set of operations without having to press enter...

    so scanf("%c", &choice);

    then when the certain character is pressed a set of instructions will happen... without having to press enter during the scanf?

    thanks alot,
    Lippy

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Posts
    230
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I dont believe there is any standard way to do that. It depends on what platform and what functions your compiler has implemented. For example, on Windows and with MSVC compiler, _getch() and _getche() defined in <conio.h> do what you want.

    If your compiler doesn't implement a function like that, you can always write your own, which isn't an easy task really.

  • #3
    New Coder
    Join Date
    Nov 2003
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This works great! Thanks alot...
    Lippy


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •