Ø Variable
Attributes:
Ø Visibility:
Ø void func()
{
int x;
{
// x is visible here
}
}
Ø void func()
{
int x;
{
int x;
// outer x is not visible here
}
}
Ø Scope:
è Global
scope – file scope – function scope – block scope
è In the
previous example:
Ø outer x scope
is its block (outer block)
Ø but it is
not visible in the inner block (due to inner block variable with the same name)
Ø Life Time:
è For local
variables:
Ø static:
lifetime = program time
Ø automatic:
life time = function time
Ø dynamic:
malloc() and free()
è For global
variables (global and file local)
Ø lifetime =
program time