> Pls help me volatile and restrict keyword programs in C++?

Pls help me volatile and restrict keyword programs in C++?

Posted at: 2014-12-18 
pls help me volatile and restrict keyword programs in C++

volatile means the variable could be changed by an outside source, so when using the variable, read it first and don't assume its the same as the last value used for it.

int a;

volatile int b;

int c, d;

c = a;

...

d = a;

//in the bit of code above, the value of variable a may be transferred to a local register so it doesn't have to read it every time (a may be some external memory location or something like that). So c and d will hold the same value even IF the memory location for variable a has changed.

Now:

c = b;

...

d = b;

Now using volatile variable the register will be read each time the variable is used and NOT stored in some local register. So c may not be the same as d. If the memory location for b changed between assigning the value to c and d, d will have the updated value.

I have never used, and don't know of the keyword "restrict".

best place to get help with programming is at stackoverflow.But you will have to write some code before you can get help

pls help me volatile and restrict keyword programs in C++