difftime() Find the Difference between Two Times
#include <time.h>
double difftime(time2,time1);
time_t time2; Type 'time_t' defined in <time.h>
time_t time1; Type 'time_t' defined in <time.h>
Difftime() computes the difference between 'time2' and 'time1'.
Returns: A double precision number representing the elapsed time in
seconds of 'time2' - 'time1'.
-------------------------------- Example ---------------------------------
The following statements open a file, set the start time, process the
file, set the end time, then find out how much time it took to process
the file.
#include <time.h>
#include <stdio.h>
time_t time1, time2;
FILE *in;
int x;
main()
{
if ((in = fopen("acct.dat","w+")) != NULL) {
time(&time1);
for (x = 1; x < 15000; x++)
fputc(x,in);
rewind(in);
while (!feof(in)) {
fgetc(in);
}
time(&time2);
printf("Time it took to process the file: %f\n",
difftime(time2,time1)
}
}
Seealso:
This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster