Mega Code Archive

 
Categories / C / Code Snippets
 

Return number of clock ticks since process start

#include <stdio.h> #include <time.h> void wait ( int seconds ) { clock_t endwait; endwait = clock () + seconds * CLK_TCK ; while (clock() < endwait) { } } int main () { int j; printf ("Starting count down...\n"); for (j = 20; j > 0; j--) { printf (" j = %d\n",j); wait (1); } printf ("Done!!!\n"); return 0; }