Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Yogurt2004

C++ Sleep command??

This topic is 5421 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys just wondering if you guys new a command to make the computer wait a certain amount of time and then proceede for example: sleep(1) would make it wait 1 second then go on to the next line of code Im am using Visual C++ and would like to know the header file that needs to be included as well ALSO: if you know how to clear the screen that would be great as well. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Sure:
Sleep(1000); // Will suspend thread for 1 second

It's in windows.h...also note the capital 'S'


-Madgap

[edited by - Madgap on January 13, 2004 3:45:49 PM]

Share this post


Link to post
Share on other sites
http://mail.gnu.org/archive/html/gnugo-devel/2001-11/msg00016.html
(Sleep question)

#include <stdlib.h>
system("cls");

that should clear your screen in windows

Share this post


Link to post
Share on other sites
Nex2Null, I think he was asking about suspending tasks on the program, not clearing the screen. (And system() is used for DOS and is the equivalent of typing cls at the command prompt)

"There are 10 kinds of people in this world, those who know binary, and those who don''t"

Share this post


Link to post
Share on other sites
quote:
Original post by Yogurt2004
ALSO: if you know how to clear the screen that would be great as well. Thanks


quote:
Original post by 4TheKing
Nex2Null, I think he was asking about suspending tasks on the program, not clearing the screen. (And system() is used for DOS and is the equivalent of typing cls at the command prompt)

"There are 10 kinds of people in this world, those who know binary, and those who don''t"


You missed something there...

Anyway, C has a function (which is obviously compatible with C++):

void sleep (unsigned int seconds)

that does just what you want. Nearly any of the standard includes should end up including it, but if necessary it can be found in dos.h.

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!