Volatile Klíčové slovo v c

Příklady kódu

1
0

Proč volatile Klíčové slovo se používá pro?

Using volatile  Keyword is yet another way (like synchronized,
atomic wrapper) of making class thread safe. Thread safe
means that a method or class instance can be used by 
multiple threads at the same time without any problem.

1
0

deklarovat Volatilní v c

//volatile keyword usage in C
#include<stdio.h>

int main(){
    //different methods of declaring and initializing volatile variables

    //method 1 - volatile int
    int volatile number1 = 10;

    //method 2 - volatile int
    volatile int number2;
    number2 = 20;

    //method 3 - volatile pointer
    int volatile *p1;
    p1 = &number1;

    //method 4 - volatile double pointer
    volatile int **p2;
    p2 = &p1;
    
    printf("%d %d %d %d",number1,number2,*p1,**p2);
    return 0;
}
1
0

volatile Klíčové slovo v c

C's volatile keyword is a qualifier that is applied to a variable when it is declared. It tells the compiler that the value of the variable may change at any time--without any action being taken by the code the compiler finds nearby.

Související stránky

Související stránky s příklady

V jiných jazycích

Tato stránka je v jiných jazycích

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................