Home Contact About

Declaring a variable as Volatile


ANSI standard defines qualifier volatile that could be used
to tell explicitly the complier that a variable's value may be changed at any time
by some external sources(from outside the program).
volatile int date;

Remember that the value of a variable declared as volatile can be modified by it's own
program as well. If we wish that the value must not be modified by the program while its own
as well. If we wish that the value must not be modified by the program while it may be altered
by some other process, then we may declare the variable as both const and volatile
as shown below:
volatile const int location = 100;