C I/O Question

Joseph S. D. Yao jsdy at hadron.UUCP
Thu Jul 31 15:13:30 AEST 1986


In article <1222 at inuxc.UUCP> lar at inuxc.UUCP (L Reid) writes:
>Is there a way to input a character from stdin without requiring
>the user to terminate it with a <CR>.

Several ways.  All involve doing an stty() or an ioctl()
call (depending on which version of Unix you have, or which
you feel more comfortable with -- starting from scratch, use
ioctl() if you have it).
The simplest and most general is to go into 'raw' mode.  If
you are ceertain you'll never use a pre-V7 machine, 'cbreak'
mode might be better, depending on your intentions.
If you have System V, you can also set a minimum number of
chars before input returns, and/or a timeout.
-- 

	Joe Yao		hadron!jsdy at seismo.{CSS.GOV,ARPA,UUCP}
			jsdy at hadron.COM (not yet domainised)



More information about the Comp.lang.c mailing list