I was wondering if someone could help me with this:
I have a countdown that uses Sleep(); for the pause and Do-While for the loop.
I was thinking that somewhere in the middle of the code, maybe in the do{ } part of it, before it loops, it could ask for a user to hit a key to stop the program.
But if they don't before the next number appears, it stops asking for the user input until it passes by the cin function again and repeats the process until either:
A) The user hits a key
B) The countdown reaches 0 (zero).
// Do-While Practice with Sleep
// Set-Up
#include <iostream>
#include <cstdlib>
#include <windows.h>
usingnamespace std;
// Main
int main()
{
cout << "Do-While Practice :D" << endl;
int a = 100;
do
{
Sleep(500);
cout << a << endl;
a--;
} while (a != -1);
system("PAUSE");
return 0;
}
...But do not know how to or if I can deploy my idea. I use system("PAUSE") because to an inexperienced Windows user, it would seem that the program stopped working.