
-----------------------------------
liangchenen
Thu Jun 09, 2005 2:16 pm

how to do delay in C++
-----------------------------------
If you have ever used turing, there's a delay function. 
it looks like this 
delay(1000);
1000 means 1 second
and the program will stop for 1 second, and continue on.
does anybody know how to do that?

-----------------------------------
rdrake
Thu Jun 09, 2005 3:15 pm


-----------------------------------
I believe it is:
sleep(1000);

-----------------------------------
liangchenen
Thu Jun 09, 2005 7:51 pm


-----------------------------------
what do I have to include for that?

-----------------------------------
md
Fri Jun 10, 2005 1:04 am


-----------------------------------
***On windows only***

include 

and then you can use the Sleep(); function. Be warned that it is not very exact, so if you tell it 1000 you might get 1010. A more exact, yet slightly worse way it to get the start time using the starndard time(); function and then poll it until the new time is greater then the start time plus your delay. 

I don't know what time standard time(); uses, it might be the unix time format... but if you do a quick google I'm sure you'll find all you need. Oh, and the header is  I think... again, google is your friend.
