I want to break out of a while loop if the User pressed any key during a Sleep(miliseconds), as in stop if any key is pressed during those miliseconds. How do I do that? The loop looks like this:
while (1)
{
r = rand() % 5501 + 1000;
Sleep(r);
cout << "NOW!\n";
t = clock() / 1000;
system("pause");
if (clock() / 1000 < t + 1)
{
cnt++;
cout << "Aaaaand...\n";
}
else break;
}
Platform: Windows