RAD Studio |  |

difftime

Header File

time.h

Category

Time and Date Routines

Prototype

double difftime(time_t time2, time_t time1);

Description

Computes the difference between two times.

difftime calculates the elapsed time in seconds, from time1 to time2.

Return Value

difftime returns the result of its calculation as a double.

Example

Copy Code

    #include <time.h>
    #include <stdio.h>
    #include <dos.h>
    #include <conio.h>
    int main(void)
    {
       time_t first, second;
       clrscr();
       first = time(NULL);  /* Gets system
                               time */
       delay(2000);         /* Waits 2 secs */
       second = time(NULL); /* Gets system time
                               again */
       printf("The difference is: %f seconds\n",difftime(second,first));
       getch();
       return 0;
    }

Portability

POSIX | Win32 | ANSI C | ANSI C++
+ | + | + | +

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!