basics · intermediate · ~15 min
Use static storage duration for state that persists across calls.
Implement int counter_next(void) that returns 1 on its first call, 2 on the next, and so on, using a static local variable to remember state between calls.
int counter_next(void) {
/* TODO: use a static local */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.