C Scope Rules
1. In any programming, a scope is a region of a variable defined in a program that cannot be accessed beyond that region variable. There are three places in C that can declare a variable:
A local variable inside a function or block
Global variables outside of all functions
In the function parameter definition of the formal parameter
2. Local Variables
A variable declared inside a function or block is called a local variable. They can only be used by the function or by statements inside the code block. Local variables are not known outside of the function.
3. Global variables
A global variable is defined outside a function, usually at the top of a program. Global variables are valid throughout the program life cycle and can be accessed within any function.
Global variables can be accessed by any function. In other words, global variables are available throughout the program after the declaration.
4. Formal parameters
function parameters, formal parameters, are treated as local variables within the function, and they override global variables preferentially.
5. Initializing local variables and global variables
When a local variable is defined, the system does not initialize it, and you must initialize it yourself. When you define a global variable, the system automatically initializes it.
C Basic Knowledge "scope rules"