difftime

difftime is a function that returns the difference between two time instants. The times are encoded and stored in variables of the type time_t. The function will return the number of seconds between the two times.

The function difftime requires two arguments of type time_t. The return value is of type double.

Example

The following code shows an example of the time function:

#include 
#include 

int main()
{
        time_t t1, t2;
        t1 = time(NULL);
        // ...
        // many other tasks
        // ...
        t2 = time(NULL);
        printf(\"the time difference in seconds is %lf\\n\", difftime(t2, t1));
        return 0;
}
Article created on 2008-08-19 21:49:11

Post a comment