how to do delay in C++
Author |
Message |
liangchenen
|
Posted: Thu Jun 09, 2005 2:16 pm Post subject: 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? |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
rdrake

|
Posted: Thu Jun 09, 2005 3:15 pm Post subject: (No subject) |
|
|
I believe it is:
|
|
|
|
|
 |
liangchenen
|
Posted: Thu Jun 09, 2005 7:51 pm Post subject: (No subject) |
|
|
what do I have to include for that? |
|
|
|
|
 |
md

|
Posted: Fri Jun 10, 2005 1:04 am Post subject: (No subject) |
|
|
***On windows only***
include <windows.h>
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 <time.h> I think... again, google is your friend. |
|
|
|
|
 |
|
|