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
- Auto
- Static
- Extern
- Register
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".
<storage_class_specifier> <data_type> <variable_name>;
For examples on storage class follow example series in this blog.
No comments:
Post a Comment