What is the difference between “File scope” and “program scope”

后端 未结 4 1151
南旧
南旧 2021-01-31 18:51

A variable declared globally is said to having program scope
A variable declared globally with static keyword is said to have file scope.

For example:

<         


        
4条回答
  •  梦谈多话
    2021-01-31 19:39

    A variable with file scope is only visible from its declaration point to the end of the file. A file refers to the program file that contains the source code. There can be more than one program files within a large program. Variables with program scope is visible within all files (not only in the file in which it is defined), functions, and other blocks in the entire program. For further info. check this : Scope and Storage Classes in C.

提交回复
热议问题