Can some one tell me if this is the right way using clock
ThanksCode:#include <time.h> int main() { int secs=0; clock_t begin; begin = clock(); secs = begin/CLOCKS_PER_SEC; }
Can some one tell me if this is the right way using clock
ThanksCode:#include <time.h> int main() { int secs=0; clock_t begin; begin = clock(); secs = begin/CLOCKS_PER_SEC; }
Yes, that looks correct. Of course, clock() returns 0 the first time it is called (and thereafter it returns the time since it was first called) -- so secs in your example will always be zero.
Also: you should return zero, and consider indenting your code.
Code:#include <stdio.h> #include <time.h> int main() { clock(); /* . . . some complicated process . . . */ printf("That took %d seconds.\n", clock() / CLOCKS_PER_SEC); return 0; }
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Thanks for that, if you could answer my question on the sockets in the other post be great, as totally confused myself with the non blocking stuff