Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#include <stdio.h>
#include <time.h>
void baz ( void ) {
volatile int i;
for(i=0;i<10000000;i++);/* work */
}
int main ( int argc, char *argv[] ) {
clock_t t1, t2;
t1 = clock();
baz();
t2 = clock();
printf("%f\n", ((double)t2 - t1)/CLOCKS_PER_SEC );
return 0;
}
t1 = clock();
for ( i = 0 ; i < 100 ; i++ ) baz();
t2 = clock();
printf("%f\n", ((double)t2 - t1)/CLOCKS_PER_SEC/100 );
In short, if you havedraft c99 said:A volatile declaration may be used to describe an object corresponding to a memory-mapped
input/output port or an object accessed by an asynchronously interrupting function. Actions on
objects so declared shall not be ‘‘optimized out’’ by an implementation or reordered except as
permitted by the rules for evaluating expressions.
volatile int a;
a = 2;
a = 3;