clock
raw OCR
Determines processor time.
Defined in header <time.h>
Syntax
#include <time.h>
clock_t clock(void);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ |
Remarks
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
The clock function returns the processor time elapsed since the beginning of the program invocation. If the processor time is not available, or its value cannot be represented, the function returns the value -1.
See also
Example
#include <time.h>
#include <stdio.h>
#include <dos.h>
int main (void)
clock_t start, end;
start = clock 0 ;
delay (2000),•
end = clock 0 ;
printfC'The time was: %f\n", (end - start) / CLK_TCK)
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/time.h/clock/
· short form /3.1/clock/