A static variable has a file scope if variable is outside of the function means it can be accessed into the file in which it is defined. Where is a global variable can be accessed in all the files of a executable.
File a.c
static int a;
int b;
File b.c
// In this file we can access b but not a.
When a static variable is defined inside a function that mean this variable i=has a function scope and would retain the value even after the control leaves the function and the same function is called again then last stored value can be accessed.
func()
{
static int a=5;
a++;
printf("%d\n", a)
}
on the first call value will be printed as 6 and next function call it would be 7.