Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fopen(S)

getc(S)

gets(S)

printf(S)

putc(S)

puts(S)

read(S)

scanf(S)

write(S)



     FREAD(S)                 XENIX System V                  FREAD(S)



     Name
          fread, fwrite - Performs buffered binary input and output.

     Syntax
          #include <stdio.h>

          int fread (ptr, size, nitems, stream)
          char *ptr;
          int size, nitems;
          FILE *stream;

          int fwrite (ptr, size, nitems, stream)
          char *ptr;
          int size, nitems;
          FILE *stream;

     Description
          fread reads, into a block beginning at ptr, nitems of data
          of the type of *ptr from the named input stream, where an
          item of data is a sequence of bytes (not necessarily
          terminated by a null byte) of length size.  fread stops
          appending bytes if an end-of-file or error condition is
          encountered while reading stream, or if nitems items have
          been read. fread leaves the file pointer in stream, if
          defined, pointing to the byte following the last byte read,
          if there is one.  fread does not change the contents of
          stream.  It returns the number of items actually read.

          fwrite appends at most nitems of data of the type of *ptr
          beginning at ptr to the named output stream.  fwrite stops
          appending when it has appended nitems items of data or if an
          error condition is encountered on stream.  fwrite does not
          change the contents of the array pointed to by ptr.  fwrite
          increments the file pointer in stream, if defined, by the
          number of bytes written.  It returns the number of items
          actually written.

     See Also
          fopen(S), getc(S), gets(S), printf(S), putc(S), puts(S),
          read(S), scanf(S), write(S)

     Diagnostics
          fread and fwrite return the number of items read or written.
          If sizeof or nitems is non-positive, no characters are read
          or written and 0 is returned by both fread and fwrite.










     Page 1                                           (printed 8/7/87)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026