#: 4581 S3/Languages
23-Jun-90 17:00:16
Sb: #4565-Help 'c' problem again
Fm: Bruce MacKenzie 71725,376
To: SCOTT HOWELL 70270,641
Buffered FILE I/O using the standard library functions is line oriented and not
well suited to reading single keypresses. It's better to use the low level
system call functions for this purpose:
read(fileno(stdin),&c,1);
This will stop and return the next keypress. If you don't want the routine to
hang until a key is pressed use getstat() to check for data available:
if(getstat(1,fileno(stdin))==0)
read(fileno(stdin),&c,1);
|