In C the static
keyword is used in 2 cases:
-
For variables:
int fun() { static int count = 0; count++; return count; }
Even if
function
has been executed, the value ofa
is kept in memory. So, in this example, every time we call this functiona
is incremented by 1. -
For functions:
static int function() { // ... }
This function is visible only by functions in the same file (translation unit).