[LBo] c/c++ one keystroke input without waiting for "Enter"
Loren Lockwood
lockwoodlo at cantv.net
Wed Feb 21 21:56:31 CET 2007
Chris F.A. Johnson wrote:
> 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>
Thanks Billy and Chris. I had been trying to use strictly ANSI c stdio
(or c++ iostream) to do the job. I figured that ncurses was cheating,
sort of like conio under MS OS's. Now I understand that there is no way
to do what I wanted. I'll just stick to ncurses and let my son make the
translation to conio terms.
Again, many thanks.
--
Gramps
More information about the QnA
mailing list