How can there be so many scopes in C language?
What is the scope first? As the name implies, the scope is the scope that something can work. Of course, this interpretation is too general. In C, the scope refers to declaring a variable, the region to which this variable can be accessed is its scope. The accessed area of this variable is determined by the scope of the variable identifier. The identifier scope is the area in the program where the identifier can be used. The C language compiler can be divided into four scopes: File Scope, function scope, code block scope, and prototype scope. Code block scope: a statement in a pair of braces is a code block. variables that can be used in a pair of braces have the characteristics of code scope. A local variable is a variable with a code block scope. It can only be used within the braces that declare it, and can only be used for its own code block. Other code blocks cannot use it. File Scope: variables outside the code block used have the characteristics of this file scope. From the declaration to the end of the source file, it can be accessed. A typical example is a global variable. It is usually declared before the main function and exists throughout the source file execution process until the source file ends, but other source files cannot be accessed. Prototype scope: the prototype scope is only applicable to parameter names declared in the function prototype. parameter names can be omitted in the function prototype. However, if a parameter name appears, it can be randomly named, the prototype scope prevents the parameter names from conflicting with the names of other parts of the program. Function scope: the function scope applies only to statement labels, while the statement labels apply to goto statements. The rule is that the statement labels used in a function must be unique. (Not commonly used)