Question 10 · 12 points
Binary record processor
Implement copy_matching_records.
typedef struct {
int id;
unsigned flags;
double value;
} record_t;
size_t copy_matching_records(
FILE *input,
FILE *output,
int (*matches)(const record_t *)
);
Read record_t values using fread, test each complete record using matches, write matching records using fwrite, and return the number successfully written. Correctly handle end-of-file, partial reads, and write failures. Explain how the caller can distinguish a clean EOF from an input error if your function’s return type cannot report both directly.