[prev] [index] [next]

The fread function

int fread(void *b, size_t z, size_t n, FILE *f);
  • uses stream f, which is open for reading
  • reads n data items, each of size z bytes
  • items are stored in memory buffer at address b
  • returns the number of items successfully read (nr)
  • at end-of-file or on error,   0 <= nr < n
  • void* means that buffer b could hold any type