Read
http://www.acm.uiuc.edu/webmonkeys/b...uide/2.15.html for details of time.h header file...
Excerpt:
2.15.3 clock
Declaration:
clock_t clock(void);
Returns the processor clock time used since the beginning of an implementation-defined era (normally the beginning of the program). The returned value divided by CLOCKS_PER_SEC results in the number of seconds. If the value is unavailable, then -1 is returned
Example:
#include<time.h>
#include<stdio.h>
int main(void)
{
clock_t ticks1, ticks2;
ticks1=clock();
ticks2=ticks1;
while((ticks2/CLOCKS_PER_SEC-ticks1/CLOCKS_PER_SEC)<1)
ticks2=clock();
printf("Took %ld ticks to wait one second.\n",ticks2-ticks1);
printf("This value should be the same as CLOCKS_PER_SEC which is %ld.\n",CLOCKS_PER_SEC);
return 0;
}
From the above example, it is easy to see how to find time of execution in seconds....
{
...
int timeTaken;
clock_t ticks1, ticks2;
ticks1=clock();
{things to be done for which time taken is to be calculated}
ticks2=clock();
timeTaken=ticks2/CLOCKS_PER_SEC-ticks1/CLOCKS_PER_SEC;
}
Hope this helps...
Arun