Skip to main content

Practice ยท 4 of 5

Build an Opaque Cache

CHALLENGE
Difficulty: advanced+25 XP

Implement a tiny fixed-size cache behind an opaque API: cache_t *cache_create(size_t cap), int cache_put(cache_t *c, int key, int value) (returns 1 stored, 0 full), int *cache_get(cache_t *c, int key) (returns NULL on miss). Keep the struct definition in your source; the tests only use the functions โ€” that is the opacity contract.

Back to lesson: Practice: Pointer Semantics Drills