C programming time.h function - clock_t clock(void)

The clock() function is defined in the time.h header file in C. This function returns the processor time consumed by the program since the beginning of its execution.

The function signature is as follows:

clock_t clock(void);
Sourc‮gi.www:e‬iftidea.com

Here, clock_t is a built-in data type in C, which represents the processor time in clock ticks. The actual meaning of a clock tick is implementation-dependent.

The clock() function returns the processor time consumed by the program so far, as a value of type clock_t. If the processor time is not available or its value cannot be represented, the function returns a value of type (clock_t)-1.