[comp.os.os9] single character read revisited

neviatar@ruunsa.fys.ruu.nl (Hadass Eviatar) (11/07/90)

Hiya netters,

Turns out I was asking for help on the wrong problem. This is what
actually happened:

What I was trying to do is:

 while (FOREVER)
  {
   count = read (0, &buffer, 1);
   printf ("# = %d, char = %d\n", count, buffer);
  }

It appeared that the print-out for the first character didn't
occur until the second character was typed. I thought that this
was caused by the buffering of read.
When I changed the c-code to:

 while (FOREVER)
  {
   count = read (0, &buffer, 1);
   write (1, &buffer, 1);
  }

It worked without any problem. Apparently, the buffering-problem
is in printf, not in read.

In any case, many thanks to all the people who took the trouble to
give me excellent advice!

hhhhhhhhhhhhh

====================================================================
Hadass Eviatar, Dept. of Molecular Biophysics, University of Utrecht
Physically:  Buys Ballot Laboratory, Princetonpl. 5, 3584 CC Utrecht
Electronically:                           neviatar@ruunsa.fys.ruu.nl
Acoustically:                                 030 - 531555/2839/2951

Always yield to temptation - Oscar Wilde.
====================================================================