Each local variable in a function comes into existence only when the function is called, and disappears when the function is exited.This is why such variables are usually
known as automatic variables.
函数中的每个局部变量仅仅会在该函数被调用时存在,当该函数退出时,这些局部变量会消失。这也是为什么这些变量被看成是automatic自动变量。
Because automatic variables come and go with function invocation, they do not retain their valus from one call to the next, and must be explicitly set upon each entry. If
they are not set, they will contain garbage.
因为自动变量会随着函数的调用产生和消失,他们的值会在进行下一个调用时消失,所以在每次进入函数时,必须明确地设置变量值。如果没有被设置,他们可能包含垃圾。
The usual practice is to collect extern declarations of variables and functions in a separate file, historically called a header, that is included by #include at the front of each source file. The suffix .h is conventional for header names.
通常实际的操作是吧变量和函数的外部声明(extern)存放在一个独立的文件里,在历史上被叫作头文件(header),在每个源文件的开头用#include来包含,后缀.h会方便地表示头文件名。
You should note that we are using the words definition and declaration carefully when we refer to external variables in this section. "Definition" refers to the place where the variables is created or assigned storage; "declaration" refers to places where the nature of the variable is stated but no storage is allocated.
你应该注意,当我们针对外部变量(external)使用定义(definition)和声明(declaration)这两个字时应该非常注意。定义(definition)指的是这个地方变量被创建或者被分配内存;声明(declaration)指的是这个地方变量的性质被声明,但是没有分配内存。
虽然extern外部变量能够使所有事情近在眼前,参数列表变短,当你需要的时候变量一直存在,这似乎简化了通信。但是即使你不用的时候外部变量也依然会在那。严重依赖外部变量会充满着危险,因为这导致了数据连接非常不明显————变量会在不可知和无意的情况下被改变,而且程序很难修改。还有一个原因这会毁坏函数的通用性。所以,滥用外部变量可能会写出劣质的程序。