how can I get my program to wait for a second before it does the next command?
I tried
for(i=0; i<10000; i++) {}
but on a pentium 3/1000mhz it doesn't slow it down at all. surely there is a better way.
how can I get my program to wait for a second before it does the next command?
I tried
for(i=0; i<10000; i++) {}
but on a pentium 3/1000mhz it doesn't slow it down at all. surely there is a better way.
My site to register for all my other websites!
'Clifton Bazaar'
what compiler?
ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.
microsoft vc++
My site to register for all my other websites!
'Clifton Bazaar'
you need to include stdlib.h
and call this function where you want it to wait
_sleep( numberofmillisecondsgoeshere );
ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.
thanks, I have 4 text books and tried to look for 'wait' or 'sleep' but couldn't find anything.
My site to register for all my other websites!
'Clifton Bazaar'
As you have MSVC, you may wish to wander down the WinAPI road;Originally posted by phantom
thanks, I have 4 text books and tried to look for 'wait' or 'sleep' but couldn't find anything.
From MSDNCode:Sleep The Sleep function suspends the execution of the current thread for a specified interval. VOID Sleep( DWORD dwMilliseconds // sleep time in milliseconds ); Parameters dwMilliseconds Specifies the time, in milliseconds, for which to suspend execution. A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If there are no other threads of equal priority ready to run, the function returns immediately, and the thread continues execution. A value of INFINITE causes an infinite delay. Return Values This function does not return a value.
Dont forget the <windows.h>
Not to the millisecond, but works with everthing.
PHP Code:
#include <time.h>
int wait(int SecondsToWait)
{
time_t TheTime = time(NULL);
while(time(NULL) - TheTime < SecondsToWait);
return 1;
}
"If you tell the truth, you don't have to remember anything"
-Mark Twain
cheers all, I'll try the differant ways and see what works best.
quick question for code monkey -> what's the reason for 'return 1'?
It may be a stupid question but i'm asking it anyway
Last edited by phantom; 01-28-2002 at 07:00 AM.
My site to register for all my other websites!
'Clifton Bazaar'