Monday, July 13, 2020

Storage Class Specifiers in C


Storage class specifiers in C language instructs the compiler where to store a variable, how to store the variable, what is the initial value of the variable and life time of the variable. There are four types of storage class specifiers in C, they are 
  1. Auto
  2. Static
  3. Extern
  4. Register
The following table makes you to understand about them better


Important points to be known:
  • For faster accessing a variable should be declared as a register. Because register variables are stored in CPU registers not in Main Memory so fetching will be faster.
  • Static variable once initialized cannot be changed. It can never be reset after initialization.
  • volatile and const has something to do with storage but they are qualifiers not a storage class.
  • typedef is also a storage class in c as declaring it before a storage class will throw an error "multiple storage class for a variable".
Syntax:

<storage_class_specifier>  <data_type> <variable_name>;

For examples on storage class follow example series in this blog.

No comments:

Post a Comment

Exploring float data type in C

Float is one among the basic data type in C.  Floating point numbers in C has precision up to 6 decimal places.  T he header file float.h de...