As the static prefix suggest the variable is in static memory that contains variables whose addresses is known at compile time (a somewhat pedantic way to say with global variables). That different from automatic variables (allocated on the stack) and dynamic variables (allocated on the heap using malloc).
The initialization of static variables in functions (or other static) is performed before the program is run. More precisely it means it can only be some constant expression, that the compiler can get at compile time.
That means the following program is not valid:
int f(int x){
return x+1;
}
int main(){
static int a = f(1);
return a;
}
When I compile it with gcc it complains as expected with the following message:
error: initializer element is not constant
However when the program run you can change the value of static variables as any other one.