PUTC(III)                    6/12/72                    PUTC(III)


     putc  -  buffered output


     mov     $filename,r0

     jsr     r5,fcreat; iobuf

     fcreat(file, iobuf)

     char *file;

     struct buf *iobuf;

     (get byte in r0)

     jsr     r5,putc; iobuf

     putc(c, iobuf)

     int c;

     struct buf *iobuf;

     (get word in r0)

     jsr     r5,putw; iobuf

     putw(w, iobuf);

     int w;

     struct buf *iobuf;

     jsr     r5,flush; iobuf


     struct buf *iobuf;


     Fcreat creates the given file (mode 666)  and  sets  up  the

     buffer iobuf (size 518 bytes); putc and putw write a byte or

     word respectively onto the file; flush forces  the  contents

     of  the  buffer  to be written, but does not close the file.

     The format of the buffer is:

     iobuf:  .=.+2           / file descriptor

             .=.+2           / characters unused in buffer

             .=.+2           / ptr to next free character

             .=.+512.        / buffer

     Or in C,

     struct buf {

             int fildes;

             int nunused;

             char *nxtfree;

             char buff[512];


     Fcreat sets the error  bit  (c-bit)  if  the  file  creation

     failed  (from  C,  returns  -1);  none of the other routines

     returns error information.

     Before terminating, a program should call flush to force out

     the last of the output (fflush from C).

     The user must supply iobuf, which should  begin  on  a  word


     To write a new file using the same buffer,  it  suffices  to

     call [f]flush, close the file, and call fcreat again.


     creat(II), write(II), getc(III)


     error bit possible on fcreat call.