Skip to main content

Practice · 2 of 4

The Stateful Function

CHALLENGE
Difficulty: intermediate+25 XP

Implement int next_id(void) using a function-scope static: first call returns 1, then 2, 3, ... forever. Also implement void reseed_ids(int n) which sets the counter so the next next_id() returns n (n >= 1).

Back to lesson: Practice: Duration & Linkage Gym