Skip to content

Instantly share code, notes, and snippets.

@BornThisWay
Last active December 15, 2015 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BornThisWay/5227592 to your computer and use it in GitHub Desktop.
Save BornThisWay/5227592 to your computer and use it in GitHub Desktop.
Wait for a period of time: write delay loop
#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