Practice ยท 2 of 3
Flush Only When Full
CHALLENGE
Difficulty: advanced+25 XP
ISO C design of stdio's rule. Given struct bw { char buf[64]; size_t n; int flushes; }; (zero-initialized before use), implement void bw_write(struct bw *w, const char *s, size_t len) โ append bytes; the moment one more byte would exceed 64, flush first (flushes++, n=0) and continue. Implement size_t bw_pending(const struct bw *w) returning w->n. NULL guards: w or s NULL with len>0 does nothing.
Press Submit to check your solution.
Back to lesson: Practice: I/O Mechanics Drills