C Tutorial/time.h/difftime — различия между версиями

Материал из C\C++ эксперт
Перейти к: навигация, поиск
м (1 версия: Импорт контента...)
 
(нет различий)

Текущая версия на 13:32, 25 мая 2010

difftime

Item Value Header file time.h Declaration double difftime(time_t time2, time_t time1); Return returns the difference, in seconds, between time1 and time2( time2 - time1).


<source lang="cpp">#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;
 }</source>