When a static variable is defined inside a function that means it is initialized by the zero and life Time of variable is life of the program i.e. there exist even after your block is not in the execution and when the control reaches to same block or function the old value is retained.
Where when the same happen outside of a function that means variable is initialized by zero and has a file scope which means if your process have multiple files then the variable can be used only in the file in which it is defined.