file-handling · intermediate · ~15 min
Use fwrite to persist raw bytes.
Implement int write_bytes(const char *path, const char *data, int n) writing n bytes from data to path (truncating), returning the number written, or -1 if it can't be opened.
#include <stdio.h>
int write_bytes(const char *path, const char *data, int n) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.