Practical C Programming - Chapter 9

来源:互联网 发布:java下载 编辑:程序博客网 时间:2024/05/01 14:33

Chapter 9. Variable Scope and Functions

All variables have two attributes: scope and class. The scope of a variable is the area of the program in which the variable is valid. A global variable is valid everywhere(hence the name global), so its scope is the whole program. A local variable has a scope that is limited to the block in which it is declared and cannot be accessed outside that block. A block is a section of code enclosed in curly braces ({}).

_

Local variables are temporary unless they are declared static.

static has an entirely different meaning when used with global variables. It indicates that a variable is local to the current file.

0 0