The visibility (i.e. scope) and lifetime of a variable are both distinct and related.
A variable is not visible at some point in the program, but life can exist, such as the visibility of a local static variable in its function, outside the function is inaccessible, but its life is indeed the entire program's running period, and a variable lifetime end, it also has no visibility, like a local variable, As the stack space is freed, it does not exist, so the external is inaccessible.
Determining the visibility of a variable is where the variable is declared (just like a local static variable, because it is declared inside a function, so it can only be visible within the function), and determining the lifetime of a variable is the position of the variable in memory (as if the static local variable is not allocated on the stack, but is allocated in the memory static storage area, So life time is not the same as a normal local variable).
Visibility and life-time differences