unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (SunOS-4.1.3)
Page:
Section:
Apropos / Subsearch:
optional field

FREAD(3S)                                                            FREAD(3S)



NAME
       fread, fwrite - buffered binary input/output

SYNOPSIS
       #include <&lt;stdio.h>&gt;

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

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

DESCRIPTION
       fread()  reads,  into  a  block pointed to by ptr, nitems items of data
       from the named input stream stream, where an item of data is a sequence
       of  bytes  (not  necessarily terminated by a null byte) of length size.
       It returns the number of items actually read.  fread() stops reading if
       an  end-of-file  or  error  condition is encountered while reading from
       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 the
       file referred to by stream .

       fwrite()  writes at most nitems items of data from the block pointed to
       by ptr to the named output stream stream.  It  returns  the  number  of
       items  actually  written.   fwrite()  stops writing when it has written
       nitems items of data or if an error condition is encountered on stream.
       fwrite() does not change the contents of the block pointed to by ptr.

       If  size  or  nitems is non-positive, no characters are read or written
       and 0 is returned by both fread() and fwrite().

SEE ALSO
       read(2V), write(2V), fopen(3V), getc(3V), gets(3S), putc(3S), puts(3S),
       printf(3V), scanf(3V)

DIAGNOSTICS
       fread() and fwrite() return 0 upon end of file or error.



                               7 September 1988                      FREAD(3S)