DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   Clock tick (http://www.daniweb.com/forums/thread156224.html)

volscolts16 Nov 9th, 2008 2:13 pm
Clock tick
 
What is a clock tick equal to in ctime??

Freaky_Chris Nov 9th, 2008 3:16 pm
Re: Clock tick
 
Im guessing you mean in relation to realy time, you may want to use CLOCKS_PER_SEC to get things in terms of time and in terms of time to clocks for example divide clock()/CLOCKS_PER_SEC withh give you how many seconds, etc and if you want to wait for x seconds do seconds*CLOCKS_PER_SEC

Chris

ArkM Nov 9th, 2008 3:32 pm
Re: Clock tick
 
Quote:

Originally Posted by volscolts16 (Post 731981)
What is a clock tick equal to in ctime??

The time_t type is an implementation-defined arithmetic type capable of representing times. Use difftime function to get the difference between two times of type time_t in seconds as a double value:
#include <time.h>
...
    time_t t;
    time(&t);
    printf("time_t step %f sec\n",difftime(t+1,t)); // time_t precision
As usually, it's equal to 1 sec (but it's not the language standard requirement).


All times are GMT -4. The time now is 3:36 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC