cybersecurity · beginner · ~15 min
Cap a write at the buffer size.
Implement int safe_write_len(int want, int buf_size) returning how many bytes you can safely write (min of the two, never negative).
int safe_write_len(int want, int buf_size) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.