[LBo] c/c++ one keystroke input without waiting for "Enter"

Chris F.A. Johnson cfajohnson at teksavvy.com
Mon Feb 19 23:05:09 CET 2007


On Mon, 19 Feb 2007, Loren Lockwood wrote:

> Hi all.  I have been trying to help my son with his computer science courses. 
> The teachers all use MS software for programming, but I won't have it on my 
> computer.  His own computer runs XP, with Borland c++ as a programming 
> platform.
>
> With the MS conio routines it is easy to get a key and analyze it, without 
> the user's hitting "Enter" first.  Does anybody know how to use ANSI c or c++ 
> to get a single keystroke from the keyboard without waiting for the user to 
> press "Enter"?  I have examined the iostream classes but can't find anything 
> which allows this.  I could instantiate a new istream (or ifstream) object, 
> but I don't know how to get it to receive input from the keyboard.

         <http://c-faq.com/osdep/cbreak.html>

-- 
    Chris F.A. Johnson                      <http://cfaj.freeshell.org>
    ===================================================================
    Author:
    Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)


More information about the QnA mailing list