Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>fread</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
fread

Usage

   #include <stdio.h>
   size_t fread(const void *p,size_t sizelem,size_t n,FILE *fp);

   ANSI

Description

   Reads n elements from stream fp into the array that p points to. sizelem
   is the number of bytes in each element.

Example 

   #include <stdio.h>
   #include <stdlib.h>

   int main()
   {
       char *dest;
       int size = 1;
       int number = 256, numread;
       FILE *fp;
       if((fp = fopen("file.dat","r")) == NULL)
           return EXIT_FAILURE;
       dest = calloc(256,1);

       numread = fread(dest,size,number,fp);
       printf("Total read %d\n",numread);
       fprintf(stdout,"Data read\n %s",dest);
       free(dest);
       return EXIT_SUCCESS;
   }

Return Value

   fread returns the number of complete elements actually read. If an error
   or an end of file is encountered, it will return less than n.

See Also

   fwrite, read



See Also: fwrite read

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