- Code: Select all
Sleep(1000);
EDIT: You will need to #include <windows.h> to use Sleep(). Sometimes its already included through some other headers, sometimes not. To be safe you need to manually include it.
| Welcome | |
|---|---|
|
Welcome to the forums of AntiRTFM's Absolute N00b Spoonfeed C++ Tutorials! You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, <a href="/profile.php?mode=register">join our community today</a>! |
|
Sleep(1000);Seato wrote:I don't know if this is only for Windows, I just know this method works for windows. It's also very similar to antiRTFM's cin.get() .
You'll need to have #include <conio.h> declared at the top and then you can place getch(); wherever you want to pause until the user presses a key. This is only advantageous if you're planning to have multiple pauses within your programs, it cuts down the amount of keys you may need to type by 2 characters, which may add up to make up far the #include <conio.h> eventually!
#include <ctime>
void sleep(unsigned int mseconds)
{
clock_t goal= mseconds + clock();
while( goal > clock() );
}
int main()
{
sleep(1000);//where 1000 mseconds is equal to 1 sec.
}
Users browsing this forum: No registered users and 0 guests