Home | Projects | Notes > C Programming > Storage Classes

Storage Classes

 

Disclaimer

 

Properties of Variables

Every variable in a C/C++ program has three properties:

1. Storage Duration

Determines when memory is set aside for the variable and when that memory is released.

2. Scope

The portion of the program text in which the variable can be referenced.

3. Linkage

Determines the extent to which it can be shared by different parts of a program.

 

By default storage duration, scope, and linkage of a variable depend on where it is declared.

 

For many variables, the default storage duration, scope, and linkage are satisfactory. When they aren't, we can alter these properties by specifying an explicit storage class: auto, static, extern, or register.

 

Storage Classes in Detail

The auto Storage Class

The static Storage Class

The extern Storage Class

The register Storage Class

The Storage Class of a Function

 

Summary