anybody know how to delay a C program for a given number of milliseconds or microseconds? any help would be appreciated. thanx in advance.
anybody know how to delay a C program for a given number of milliseconds or microseconds? any help would be appreciated. thanx in advance.
wazilian
King of Wazil
It's compiler dependant. Type #include<time.h>, put your cursor on the word and hit F1 key, or else Ctrl-F1. If you have Visual Studio.NET than you can use the dynamic help.
from <windows.h> use Sleep(x) where x is number of millisecs you want to delay for.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
And you will never get beyond milliseconds with a windows OS. Microsecond sleep control is kind of pointless, anyway, because of multitasking, you're only guaranteed to wait AT LEAST a certain length of time.
So, sleep(10) will make your thread sleep for AT LEAST 10 milliseconds, but it could sleep for 10, 20, 50, a million, depending on what else is running.
The only way to avoid this is to give the thread realtime priority, but that is VERY inadvisable to use frequently, as it will steal all the processor time, not even giving anything to the routine OS tasks it always does.