Skip to main content

Rate Limiter

Challenge on lesson: Checkpoint: Scope & Storage

Implement int allow_request(void) using a static local: it returns 1 for the first 3 calls and 0 for every call after (a fixed budget of 3). Also implement void limiter_reset(void) that makes the next 3 calls allowed again — two functions sharing one file-scope static int used;.

Difficulty: beginner

Back to lesson: Checkpoint: Scope & Storage