Skip to main content
gamedev.net
🔒 Locked

Time function

Started by TEUTON Apr 9, 2006 at 5:15 AM 5 replies 750+ views
Original Post
TEUTON
TEUTON
These are two ways to use time function and both lead to the same result
start=time( 0 );

time(&start);
Is any one of it better than the other or it is redundant
TEUTON
TEUTON
*Bump*
Someone?
smart_idiot
smart_idiot
The only real difference is that start will be be set to -1 in the first example if an error happens. But I don't think it's possible for an error to happen in the first example, so I guess there's no difference that you should ever be able to notice.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other
TEUTON
TEUTON
1 more thing...
Why do we need to use difftime when I can simply subtract initial time from final time.
Silkjc
Silkjc
Asuming this is for time based movements, the 'difftime' as you say can be passed into your physics update methods, etc. Its just much neater to store the time difference in a temporary variable then to calculate it every time you wish to use the time difference value.

Don't quote me on that though, its only a stab in the dark at what your doing! :)
Oluseyi
Oluseyi
Quote:
Original post by TEUTON
1 more thing...
Why do we need to use difftime when I can simply subtract initial time from final time.

time_t is frequently defined as a long, but that is an implementation-specific choice. The Standard does not define any arithmetic properties for time_t, nor does it place any particular type constraints for it. If a particular implementation decides to represent time_t in some fashion other than as a typedef to an integral type, subtraction might not work.
TEUTON
TEUTON
ok...so basically
difftime() returns the number of seconds between two times provided as time_t variables no matter how time_t is implemented in the machine.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.