value of variable cannot be changed by programmer (due to const) but it value can be changed by external device or hardware interrupt (due to volatile).
Example:
#include<stdio.h>
const volatile int a=6;// HERE variable int a is constant so that it can't change by the programmer but it
can change external because of volatile
int main()
{
printf("canst volatile %d",a);
}
output: canst volatile 6
Example:
#include<stdio.h>
const volatile int a=6;// HERE variable int a is constant so that it can't change by the programmer but it
can change external because of volatile
int main()
{
printf("canst volatile %d",a);
}
output: canst volatile 6
0 comments:
Post a Comment