Any variable declaration can be prefixed with a type qualifier:
const or volatile. We will only describe const here
and refer the user to a more complete reference for a description of
volatile.
const is used as a `hint' to the compiler that the variable will
not be changed any point within the scope of the declaration. This
may allow the compiler to generate code optimized more efficiently, and it will
certainly warn you if you modify the variable accidentally.
|
void f(void) {
const int i=10; /* we will not modify i */
/* .. */
}
|
|
void display(const char* message) { /* the function guarantees
not to modify message */
/* .. */
}
|