C++ Create Time Delays
Posted by Samath
Last Updated: January 05, 2017

This program creates delays for user defined time in seconds. So basically this program can be used to delay a statement from excuting for a peroid of time. 

#include <iostream>
#include <time.h>
using namespace std;

void wait(int seconds)
{
	clock_t endwait;
	endwait = clock() + seconds * CLOCKS_PER_SEC;
	while (clock() < endwait) {}
}

int main ()
{
  int timetowait = 2;
  wait(timetowait);
  cout << "Hello World!\n";
  cout << "Finish!!!";
  cin.get();
  return 0;
}