hi, how can i let my C code program to stay in a while loop just for x seconds?
Depending on what you are trying to achieve you could use the sleep API. A lot simpler, just suspends the application for the designated period of time. Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Stuart
Yes, you're right. For a straightforward delay the Sleep call is easier. The C declaration is: VOID WINAPI Sleep(__in DWORD dwMilliseconds);
and you need to include the header "Winbase.h" and link against the library Kernel32.lib (both of which you may well be doing already).
You can make a crude sort of timer using standard c/c++ if portability is an issue. include time.h or ctime time_t t1, t2; t1 = time(NULL); do { t2 = time(NULL); } while(t1 + seconds_to_wait > t2);
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |