#: 8348 S3/Languages
20-Nov-90 10:00:04
Sb: #8339-C programming
Fm: Mark Wuest 74030,332
To: MAS 76336,3226 (X)
Robert,
Here's a quick-and-dirty routine to get one byte from a path you have
previously opened with open() (or use path = 0 for stdin).
cread(path,buf)
int path;
char *buf;
{
int cnt;
if((cnt = _gs_rdy(path)) < 0)
return(cnt);
if(cnt == 0)
return(cnt);
return(read(path,buf,1);
}
This should read just one byte. If there is nothing there, it returns 0.
Obviously if there is an error, it returns -1. Hope this is a good starting
place for you.
Mark
|