Type Qualifiers
- C defines type qualifiers that control how variables may be accessed or modified.
- C89 defines two of these qualifiers: const and volatile. (C99 adds a third, called restrict)
- The type qualifiers must precede the type names that they qualify.
- const Variables of type const may not be changed by your program. (A const variable can be given an initial value, however.)
- The compiler is free to place variables of this type into read-only memory(ROM).
const int a=10;
- creates an integer variable called a with an initial value of 10 that your program may not modify.However, you can use the variable a in other types of expressions. A const variable will receive itsvalue either from an explicit initialization or by some hardware-dependent means.
- The const qualifier can be used to prevent the object pointed to by an argument to a function from being modified by that function. That is, when a pointer is passed to a function, that function can modify the actual object pointed to by the pointer.
