fwrite
Writes elements to a stream
#include <stdio.h> size_t fwrite ( const void *buf, size_t elsize, size_t nelem, FILE *fp);
This function also works on the DOS partition.
The fwrite function returns the number of complete elements that are successfully written. This value is less than the requested number of elements only if a write error occurs.
The fwrite function writes nelem elements of elsize bytes each to the file specified by fp.
The following example writes a simple student record containing binary data.
#include <stdio.h> struct student_data { int student_id; unsigned char marks[10]; }; int write_data (FILE *fp, struct student_data *p) { return (fwrite ( p, sizeof (*p), 1, fp) ); }