fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <sys/time.h>
  5. #include <unistd.h>
  6.  
  7. int main (int argc, char *argv[])
  8. {
  9. double cBuffer1;
  10. double cBuffer2;
  11. time_t zaman;
  12. struct tm *ltime;
  13. static struct timeval _t;
  14. static struct timezone tz;
  15.  
  16. time(&zaman);
  17. ltime = (struct tm *) localtime(&zaman);
  18.  
  19. gettimeofday(&_t, &tz);
  20. cBuffer1 = (double)_t.tv_sec + (double)_t.tv_usec/(1000*1000);
  21.  
  22. printf(" %f \n",cBuffer1);
  23.  
  24. sleep(1);
  25.  
  26. gettimeofday(&_t, &tz);
  27. cBuffer2 = (double)_t.tv_sec + (double)_t.tv_usec/(1000*1000);
  28.  
  29. printf(" %f \n", cBuffer2);
  30.  
  31. printf(" duration : %f \n", cBuffer2-cBuffer1);
  32.  
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0s 2424KB
stdin
Standard input is empty
stdout
 1411041508.699754 
 1411041509.699849 
 duration : 1.000095