C clock()

The clock() function returns a value that approximates the amount of time the calling program has been running. To transform this value into seconds, divided it by CLOCKS_PER_SEC. A value of -1 is returned if the time is not available.

clock() Syntax

Following is the syntax of the clock() function :

clock_t clock(void);

clock() Example

Following function displays the current execution time, in seconds, for the program calling it :

void elapsed_time(void)
	printf("Elapsed time: %u secs.\n", clock()/CLOCKS_PER_SEC);

C Online Test

« Previous Function Next Function »

Like/Share Us on Facebook 😋