RAD Studio |  |

clock

Header File

time.h

Category

Time and Date Routines

Prototype

clock_t clock(void);

Description

Determines processor time.

clock can be used to determine the time interval between two events. To determine the time in seconds, the value returned by clock should be divided by the value of the macro CLK_TCK.

Return Value

On success, clock returns the processor time elapsed since the beginning of the program invocation.

On error (if the processor time is not available or its value cannot be represented), clock returns -1.

Example

Copy Code

    #include <time.h>
    #include <stdio.h>
    #include <dos.h>
    int main(void)
    {
       clock_t start, end;
       start = clock();
       delay(2000);
       end = clock();
       printf("The time was: %f\n", (end - start) / CLK_TCK);
       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!