printf, data presentation

Dave Hammond daveh at marob.MASA.COM
Fri Jan 6 00:00:20 AEST 1989


In article <8332 at ihlpl.ATT.COM> knudsen at ihlpl.ATT.COM (Knudsen) writes:
>Speaking of libraries and interactive screen programs,
>it strikes me as criminal negligence that hardly any C standard
>libs include the inkey() function, which means "check whether
>a char has been typed on the keyboard; if so, return it;
>else return \0 (or whatever).  DO NOT BLOCK."

If I understand your need, the fcntl VMIN and VTIM parameters may
help.  If you set VMIN=0 and VTIM>0, read() returns immediately
if characters are available, or in VTIM 10th-secs if the queue is dry.

I use VMIN=0,VTIM=1 to grab the next char, or return immediately if
none is available.

>Even a blocking version (that would return a char once typed,
>without waiting for a newline) would be useful.

Try reading with VMIN=1,VTIM=0.  This is akin to the Berkeley CBREAK mode.

--
Dave Hammond
...!uunet!masa.com!{marob,dsix2}!daveh



More information about the Comp.unix.wizards mailing list