static Local Variables
static inside a function keeps its value between calls.
Example
#include <stdio.h>
int counter(void) { static int n = 0; return ++n; }
int main(void) {
counter(); counter();
printf("%d\n", counter());
return 0;
}Result
3
Exercise
Keep between calls.
int n = 0;Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.