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

后端 未结 4 1191
南旧
南旧 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:27

    C programs can be written in several files, which are combined by a linker into the final execution. If your entire program is in one file, then there is no difference. But in real-world complex software which includes the use of libraries of functions in distinct files, the difference is significant.

提交回复
热议问题