#: 11739 S3/Languages
12-Aug-91 21:08:11
Sb: #11734-inkey
Fm: Bruce MacKenzie 71725,376
To: PHIL SCHERER 71211,2545
Phil,
I think I can help you out here. First, all FILE I/O is buffered. C
doesn't send anything to the screen until either a charage return is
encountered or until its buffer is full ( 256 characters by default). If you
want your first string to be sent to the screen before the inkey you either
have to put a /n at the end of it or fflush(stdout). Second, the program hangs
in inkey because it does its read system call without checking for data
available. The os9 read call sits around waiting for a keypress if there is no
data in the device driver buffer to send. You need to do something like:
If(getstat(1,fileno(stdin))==0)
read(fileno(stdin),&ch,1);
Hope this makes sense. Buffering does make keyboard/screen I/O a bit clumsy at
times.
|