difftime
double  difftime ( time_t timer2, time_t timer1 );
time.h
  cplusplus.com  

Return difference between two times.
  Calculates the time difference between timer1 and timer2 in seconds.

Parameters.

timer2
Latter time
timer1
Former time

Return Value.
  The difference in second between the two times specified.

Portability.
  Defined in ANSI-C.

Example.

/* difftime example */
#include <stdio.h>
#include <time.h>

main ()
{
  time_t start,end;
  char szInput [256];
  double dif;

  time (&start);
  printf ("Please, enter your name: ");
  gets (szInput);
  time (&end);
  dif = difftime (end,start);
  printf ("Hi %s.\n", szInput);
  printf ("You have taken %.2lf seconds to type your name.\n", dif );
 
  return 0;
}
Output:
Please, enter your name: Juan Soulie
Hi Juan Soulie.
You have taken 3.00 seconds to type your name.

See also.
  asctime, gmtime, localtime, time


© The C++ Resources Network, 2000