Programming in C

(Barry) #1
6.0 Storage Classes and Scope 453

Ta ble A.6 Va riables: Summary of Storage Classes, Scope, and Initialization
If Storage And Variable Then it can be And can be
Class is is declared referenced initialized with Comments
static Outside any Anywhere Constant Variables are
BLOCK within the file expression only initialized
Inside a BLOCK Within the only once at
BLOCK the start of pro-
gram execution;
values are
retained through
BLOCKs;
default value is 0
extern Outside any Anywhere within Constant Variable must
BLOCK the file expression only be declared
Inside a BLOCK Within the in at least
BLOCK one place with-
out the extern
keyword, or in
one place using
the keyword
externand
assigned an ini-
tial value
auto Inside a BLOCK Within the Any valid Variable is
BLOCK expression initialized each
time the
BLOCK is
entered; no
default value
register Inside a BLOCK Within the Any valid Assignment
BLOCK expression to register not
guaranteed;
varying restric-
tions on types of
variables that
can be declared;
cannot take the
address of a reg-
ister variable;
initialized each
time BLOCK is
entered; no
default value

20 0672326663 AppA 6/10/04 2:01 PM Page 453

Free download pdf