man(1) Manual page archive


     FREAD(3S)                                               FREAD(3S)

     NAME
          fread, fwrite - buffered binary input/output

     SYNOPSIS
          #include <stdio.h>

          int fread(ptr, sizeof(*ptr), nitems, stream)
          FILE *stream;

          int fwrite(ptr, sizeof(*ptr), nitems, stream)
          FILE *stream;

     DESCRIPTION
          Fread reads from the named input stream at most nitems of
          data of the type of *ptr into a block beginning at ptr. It
          returns the number of items actually read.

          Fwrite appends to the named output stream at most nitems of
          data of the type of *ptr from a block beginning at ptr. It
          returns the number of items actually written.

     SEE ALSO
          read(2), stdio(3)

     DIAGNOSTICS
          Fread and fwrite return a short count upon end of file or
          error.

     BUGS
          Write errors from fwrite may be delayed until a subsequent
          stdio(3) writing, seeking, or file-closing call.
          These routines are much slower than you might imagine.