ReadKey like Function in C
Dave Fenske
davef at lakesys.UUCP
Thu Aug 10 13:21:27 AEST 1989
In article <207600029 at s.cs.uiuc.edu> mccaugh at s.cs.uiuc.edu writes:
>
> Wait a minute -- am I missing something here? Isn't conventional (Kernighan-
> Ritchie) C supoosed to be capable of system-calls to the operating-system,
> say, to switch I/O-mode from cooked to raw, thereby obviating the <CR> on
> char-input, then switching back when done?
Absolutely! You need only do the following:
1. do an "ioctl (n, TCGETA, &term)
2. modify some parameters, such as
term.c_lflag &= ~(ICANON | ECHO) or whatever else you need
3. term.c_cc [VTIME] = some_value <- for timeout, if desired
4. term.c_cc [VMIN] = 1 <- satisfy read with 1 character
5. ioctl (m, TCSETA, &term) to reset the terminal
6. you can now do a read (n, &work, 10)
You might need/want to reset the terminal, but these are the basic steps.
More information about the Comp.lang.c
mailing list