Storage Class Specifiers
auto – Can be used only within a block. A default storage class. Stored in stack.
static – Either inside/outside the function. If used inside, a function, the scope of variable is preserved between function calls. If used outside a function but in a file, it the variable cannot be accessed by other file. Stored in data segment.
extern – Defined in a function, used somewhere else. Stored in data segment.
register – Can be used only within the function, variable stored in the CPU register.
typedef – Define identifiers with name types. Helps to read the code easier.
Type Qualifiers
const – Variable can be initialized with const, but cannot be reassigned.
volatile – Informs the compiler to not optimization the variable declared with volatile as it would be changed externally.
Note: The type specifier should come before the variable name in declaration.
Order for Declaration:
(Type specifier) (storage class specifier) (type qualifier) variable
Example:
const int var: var is a variable of constant integer type. Value of var cannot be changed.
const int *ptr: ptr is a pointer to constant integer type. The value of ptr cannot be changed but the value pointed by ptr can be changed by dereference ptr ( unless the value pointed by ptr is not declared as const)
const char **ptr: ptr is a pointer to pointer to a variable of type const char. ptr can be modified but we cannot modify the const.
const char* const ptr: ptr is a constant pointer to a constant character.
int *cost* const ptr: ptr is a constant pointer to a constant integer pointer.
int **const ptr: ptr is a constant pointer to integer pointer. ptr cannot be modified by the value pointed by ptr can be modified.
int const **ptr: ptr is a pointer to pointer to constant integer. ptr can be changed but the value pointed by ptr cannot be changed
char const *const *ptr: ptr is constant pointer to constant point to constant character . ptr, the address pointed by it cannot be changed and that character pointed by that address cannot be changed.
extern int* const (*arr[3])[4]: arr is a array of size 3 where each element is a pointer to array of size 4 which are pointed to constant pointer to integers. The definition of arr is avaiable externally.
const char* const * const *const ptr: ptr is a constant pointer to constant pointer to constant pointer to constant character pointer.
volatile float* volatile ptr: ptr is a pointer to volatile pointer pointing to volatile float type.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
An Article by: Yashwanth Naidu Tikkisetty
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
