The two binary file-processing functions are fread and fwrite. They are similar in definition:
int fread ( void * data, int size, int count, FILE * file ); int fwrite ( void * data, int size, int count, FILE * file );
The first parameter is the data to be written or read, the second is the size of each data item, the third is the number of data items, and the final parameter is the file stream, opened with a call to fopen. The use of a void pointer in the first parameter is because it is not known what kind of data will be passed to the function until it is invoked.
In addition, because the first parameter is itself a pointer, it can be cast to any type, including a pointer (reference) to a single item of data.
The following ...