Skip to main content

Practice ยท 2 of 4

The Stateful Function

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).

Difficulty: intermediate

Back to lesson: Practice: Duration & Linkage Gym