Register Storage Class In C Language

Storage Class Definition

Storage class in C decides the part of storage to allocate memory for a variable, it also determines the scope of a variable.

All variables defined in a C program get some physical location in memory where variable's value is stored.

The storage class of a variable in C determines the life time of the variable if this is 'global' or 'local'.


Register Storage Class

The register specifier declares a variable of register storage class.

Variables belonging to register storage class are local to the block which they are defined in, and get destroyed on exit from the block.

The variables defined as the register is allocated the memory into the CPU registers depending upon the size of the memory remaining in the CPU.

We can store pointers into the register, i.e., a register can store the address of a variable.

Example 1:



Output:

  15

Example 2:



Output:

	//error: address of register variable requested

Read Also: