> Date: Fri, 01 Mar 2002 22:54:24 -0500
> From: Joe Kline <joekline at strato.net>
>
> Why no replies to:
'cuz it can be answered by RTFMing? or in FAQs and/or books?
as I recall, the FAQ you want is the ``comp.lang.c'' one ....
or maybe it's because programs which don't wait for a newline,
i.e. which don't allow me to consider/correct my input before
committing to what I just typed (sans newline), are obnoxious?
> On 12-Jul-99 Stephen Shirley wrote:
> >Does anyone know what the Linux equiv of the Borland kbhit() in dos?
> >I need to check if there are more characters are waiting to be read
> >in from stdin. Also - what's the easiest way to read in _one_ character
> >from the heyboard - ie. without needing to hit return afterwards.
> Thanks,
> I need this too!! Help.
> Joe Kline
stdin need not be "the keyboard" (and not all systems have
a "keyboard" --- this is a PC/Mac/workstation fallacy).
for ttys (e.g. "the keyboard"), if ICANON is set, you cannot
read any chars until a newline is typed; see termios(3).
poll(2) can be used with some file types, including ttys,
to detect the existence of input which is ready to be read.
not all *ix systems have poll, most which do not use select(2).
reading is always done with read(2).
most likely, these hints are not what you need, as they
are all quite low-level. so look at ncurses(3NCURSES).
( these hints also assume you are dealing with characters,
and not keystrokes. they are different. <Shift> is not
a character, but its depression and its release are both
keystrokes. )
--
Innovative, very experienced, Unix and | Brian Foster Dublin, Ireland
Chorus (embedded RTOS) kernel internals | e-mail: blf at utvinternet.ie
expert looking for a new position ... | mobile: (+353 or 0)86 854 9268
For a resume, contact me, or see my website http://www.blf.utvinternet.ie
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!