Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fread(S) — System V/386 Software Development System 3.2.2b

Media Vault

Software Library

Restoration Projects

Artifacts Sought



     FREAD(S)                  UNIX System V                  FREAD(S)



     Name
          fread, fwrite - binary input/output

     Syntax
          #include <stdio.h>
          #include <sys/types.h>

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

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

     Description
          The fread function copies, into an array pointed to by ptr,
          nitems items of data 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.

          fwrite appends at most nitems items of data from the array
          pointed to by 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.

          The argument size is typically sizeof(*ptr) where the
          pseudo-function sizeof specifies the length of an item
          pointed to by ptr.  If ptr points to a data type other than
          char, it should be cast into a pointer to char.

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

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

     Standards Conformance
          fread and fwrite are conformant with:
          AT&T SVID Issue 2, Select Code 307-127;
          The X/Open Portability Guide II of January 1987;
          ANSI X3.159-198X C Language Draft Standard, May 13,
          1988;
          IEEE POSIX Std 1003.1-1988 with C Standard Language-
          Dependent System Support;
          and NIST FIPS 151-1.

                                                (printed 6/20/89)



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