Thread: input function without a need to press Enter?

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

    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?


  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    There's an FAQ entry. It has almost the same title as your thread. 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:

    Last edited by dwks; 06-19-2009 at 03:20 PM.

    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:

    My website:
    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, 08: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