Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[C] Timed Cycle

Newbie Spellweaver
Joined
Aug 21, 2005
Messages
84
Reaction score
0
hi guys

i want to ask a question... does anyone know a good way to make timed cycle? because using for (i=0;i<20000000000000000000000000000;i++) works really differently on different pc...
 
Custom Title Activated
Loyal Member
Joined
Jun 28, 2007
Messages
2,986
Reaction score
3
Try and look for sleep functions, these delay the execution of the program instead of looping (and thus using CPU!). Always use sleep and no loops for this.

windows.h has a Sleep() function, google it.
 
Newbie Spellweaver
Joined
Aug 21, 2005
Messages
84
Reaction score
0
okay, so i have found sleep () function for linux in unistd.h but the problem is that it works with Seconds, not miliseconds... any advices?
 
Custom Title Activated
Loyal Member
Joined
Jun 28, 2007
Messages
2,986
Reaction score
3
microsleep() ? Perhaps working with decimals works...10 ms is the lowest you can get though (depending on your CPU), even if you say it should be 1 ms.
 
Newbie Spellweaver
Joined
Aug 21, 2005
Messages
84
Reaction score
0
ty 4 help but i've found a better thing
usleep



WTB lib and command to change color -.- not whole screen text but some specific output and etc
 
Newbie Spellweaver
Joined
Nov 28, 2006
Messages
56
Reaction score
0
Try and look for sleep functions, these delay the execution of the program instead of looping (and thus using CPU!). Always use sleep and no loops for this.

windows.h has a Sleep() function, google it.

Also take into account that if you use the sleep fuction on a singel threaded program it will HANG ON for the said number of seconds.
 
Back
Top