Click here for important information about

staying in a while loop for x seconds

March 1, 2011 at 09:11:47
Specs: Windows XP

how can i let my C code program to stay in a while loop just for x seconds?

See More: staying in a while loop for x seconds

March 1, 2011 at 09:39:57

Report •

March 1, 2011 at 10:49:04
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)


Report •

March 1, 2011 at 12:16:20
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).

Report •

Related Solutions

March 1, 2011 at 18:36:46
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);

Report •

Ask Question