difftime : difftime « time.h « C Tutorial






ItemValue
Header filetime.h
Declarationdouble difftime(time_t time2, time_t time1);
Returnreturns the difference, in seconds, between time1 and time2( time2 - time1).


#include <time.h>
  #include <stdio.h>

  int main(void)
  {
    time_t start, end;
    volatile long unsigned t;

    start = time(NULL);
    for(t=0; t<500; t++) ;
    end = time(NULL);
    printf("Loop used %f seconds.\n", difftime(end, start));

    return 0;
  }
Loop used 0.000000 seconds.








25.5.difftime
25.5.1.difftime