TIP: Click on subject to list as thread! ANSI
echo: cis.languages
to: SCOTT HOWELL 70270,641
from: Bruce MacKenzie 71725,376
date: 1990-06-23 17:00:16
subject: #4565-Help `c` problem again

#: 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);

SOURCE: compuserve via textfiles.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.