Mega Code Archive

 
Categories / C / Development
 

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 i;   printf ("Starting count down...\n");      for (i = 20; i > 0; i--) {     printf (" i = %d\n",i);     wait (1);   }      printf ("Done!!!\n");      return 0; }