![]() |
VOOZH | about |
In C, the volatile keyword is used to inform the compiler that the value of a variable may change at any time, without any action being taken by the code in the program. It is particularly useful in embedded systems, signal handlers, and multi-threaded applications. In this article, we will learn how to use the volatile keyword in C.
We can use the for different purposes like declaring some global variables, signal handlers, variables across shared threads, etc. When a variable is declared as volatile, it tells the compiler:
volatile dataType varName;The below program demonstrates the use of volatile keyword in C.
Output
Final value of volVar: 20