input function without a need to press Enter?

This is a discussion on input function without a need to press Enter? within the C Programming forums, part of the General Programming Boards category; I'm trying to write a program that will calculate beats per minute based on tapping a key to the beat. ...

  1. #1
    Registered User chao06's Avatar
    Join Date
    Jun 2009
    Location
    College Station, TX
    Posts
    1

    input function without a need to press Enter?

    I'm trying to write a program that will calculate beats per minute based on tapping a key to the beat. I've been trying to use scanf or getc, and have the key pressed be Enter, so that it would set the variable to NULL, but that hasn't worked. Is there an input function that doesn't require an Enter to continue, just taking the first character it gets? And if not, how could I get using Enter as the key pressed to work?

    Thanks,
    David

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,047
    There's an FAQ entry. It has almost the same title as your thread. Cprogramming.com FAQ > How can I get input without having the user hit [Enter]?

    Short answer is that you can't do it portably. It depends on what compiler you're using. Are you using Dev-C++? (That I can help you with.)

    [edit] See also some of these posts of mine:

    [/edit]
    Last edited by dwks; 06-19-2009 at 03:20 PM.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. Change this program so it uses function??
    By stormfront in forum C Programming
    Replies: 8
    Last Post: 11-01-2005, 07:55 AM
  3. Is this the perfect input function?
    By Brain Cell in forum C Programming
    Replies: 30
    Last Post: 10-20-2004, 07:41 PM
  4. Getting input without the user having to press Enter...
    By Ranedhel in forum C++ Programming
    Replies: 18
    Last Post: 07-16-2003, 05:36 PM

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