Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   I want function to count the time (http://www.go4expert.com/forums/i-function-count-time-t25298/)

fulla 21Mar2011 00:49

I want function to count the time
 
hi..

i want help for function that can count the time from start function to eand it ..

in c++ thr is function but i never use it i want help how can i use it..
thanks

virxen 27Mar2011 14:50

Re: I want function to count the time
 
Code:

#include <stdio.h>
#include <time.h>

int main ( ) {
time_t t;
clock_t start, end;
long i,count= 100000000;

start = clock();

time(&t);

printf(ctime(&t));
printf( "Counting to %ld\n", count );

for (i=0; i < count; i ++);

end = clock();

printf( "That took %f seconds and I counted up to %ld", (((double)(end-start)/CLOCKS_PER_SEC)), count );
getchar();
return 0;
}



All times are GMT +5.5. The time now is 05:58.