codescracker


c

C clock()



« Previous Function Next Function »


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 :

#include<time.h>
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);
}

« Previous Function Next Function »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test