C++ Sleep command??
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
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]
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]
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
(Sleep question)
#include <stdlib.h>
system("cls");
that should clear your screen in windows
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"
"There are 10 kinds of people in this world, those who know binary, and those who don''t"
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
______________________________________________________________
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement