Showing posts with label Storage Class. Show all posts
Showing posts with label Storage Class. Show all posts

Differentiate between an internal static and external static variable?

An internal static variable is declared inside a block with static storage class whereas an external static variable is declared outside all the blocks in a file.An internal static variable has persistent storage,block scope and no linkage.An external static variable has permanentstorage,file scope and internal linkage.

Storage classes in C

Keyword : auto
Storage Location : Stack
Initial Value : Garbage Value
Life : Control remains in a block where it is defined
Scope : Local to the block in which variable is declared


Keyword : register
Storage Location : CPU Register
Initial Value : Garbage
Life : Local to the block in which variable is declared.
Scope : Local to the block


Keyword : extern
Storage Location : if uninitialized then in BSS, if initialized then in Data segment
Initial Value : Zero
Life : Until the program ends.
Scope : Global to the program


Keyword : Static
Storage Location : if uninitialized then in BSS, if initialized then in Data segment
Initial Value : Zero and can be initialize once only
Life : Depends on function calls and the whole application or program
Scope : Local to the block