static variables are permanent variables within their own function or file. Unlike global variables, they are not known outside their function or file, but they maintain their values between calls.
This feature makes them useful when you write generalized functions and function libraries that other programmers may use.
When you apply the static modifier to a local variable, the compiler creates permanent storage for it, much as it creates storage for a global variable.
The key difference between a static local variable and a global variable is that the static local variable remains known only to the block in which it is declared. In simple terms, a static local variable is a local variable that retains its value between function calls.