home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 316 / libsrc / fputc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-20  |  405 b   |  22 lines

  1.  
  2. /* fputc */
  3.  
  4. #include <file.h>
  5. #include "std-guts.h"
  6.  
  7. int fputc(c, f)
  8. char c;
  9. struct file * f;
  10. {
  11.   if (!f || !f->open_p || ((f->mode & 0x03) == O_RDONLY)) return(EOF);
  12.   if (f->buf_index >= BUFSIZE)
  13.     fflush(f);
  14.   f->buf[f->buf_index] = c;
  15.   f->buf_index++;
  16.   if (f->buf_max < f->buf_index)
  17.     f->buf_max = f->buf_index;
  18.   if (f->buf_index >= BUFSIZE)
  19.     fflush(f);
  20.   return(c & 0xFF);
  21. }
  22.