Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 how to do delay in C++
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
liangchenen




PostPosted: 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
Sponsor
sponsor
rdrake




PostPosted: Thu Jun 09, 2005 3:15 pm   Post subject: (No subject)

I believe it is:
code:
sleep(1000);
liangchenen




PostPosted: Thu Jun 09, 2005 7:51 pm   Post subject: (No subject)

what do I have to include for that?
md




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: