fread()                  Read Unformatted Data from Stream
 
 #include   <stdio.h>
 
 int        fread(buffer,size,count,stream);
 char       *buffer;                     Storage location for data
 int        size;                        Item size in bytes
 int        count;                       Max number of items to read
 FILE       *stream;                     Pointer to file structure
 
    fread() reads a maximum of 'count' items of data, each of length
    'size' bytes, from the input 'stream' and stores them in 'buffer'.
    If there is a file pointer associated with 'stream', it is
    incremented by the number of bytes actually read.
 
    Returns:    The number of items actually read.  This number may be
                less than 'count' if an error occurs or end-of-file is
                reached before reaching 'count'.
 
      Notes:    If 'stream' was opened in text mode, the replacement of
                (CR-LF) with (LF) has no effect on the file pointer
                return value.
 
  -------------------------------- Example ---------------------------------
 
    The following statements open a file and read 128 characters from the
    stream.
 
         #include <stdio.h>
 
         FILE *stream;
         char buffer[128];
 
         main()
         {
             if ((stream = fopen("book.dat","r+")) != NULL) {
                 fread(buffer, sizeof(char), 128, stream);
             }
         }

Seealso:



This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster