Last active
December 15, 2015 07:59
-
-
Save BornThisWay/5227592 to your computer and use it in GitHub Desktop.
Wait for a period of time: write delay loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <ctime> | |
int main() | |
{ | |
using namespace std; | |
cout << "Enter the delay time, in seconds: "; | |
float secs; | |
cin >> secs; | |
clock_t delay = secs * CLOCKS_PER_SEC; | |
cout << "starting\a\n"; | |
clock_t start = clock(); | |
while (clock() - start < delay) | |
; | |
cout << "done\a\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment