Electrical and Computer Engineering
9 of 19
UAH
CPE 112
Lifetime of A Variable
•Lifetime is the period of time during program execution when an identifier actually has memory allocated to it.
•Two types of variables
–Static variables – storage remains allocated for the duration of the entire program
–Automatic variables – storage is allocated at block entry and deallocated at block exit
•By default, variables declared within a block are automatics, this can be changed using the reserved word static.