Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>fread() read unformatted data from stream</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 fread()                 Read Unformatted Data from Stream

 #include   <stdio.h>

 size_t fread(buffer,size,count,stream);
 void       *buffer;                     Storage location for data
 size_t size;                            Item size in bytes
 size_t count;                           Max number of items to read
 FILE       *stream;                     Pointer to FILE structure

    fread() reads the input 'stream' and stores a maximum of 'count'
    items of data, each of length 'size' bytes, 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:    LF replaces CR-LF pairs if 'stream' was opened in text
                mode, but this does not affect either the file pointer or
                the number of items read.

   -------------------------------- 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);
               }
           }



See Also: fwrite() read()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson