Why is my C++ timer stuck in infinite loop?

From: wwwolf (abuse_at_alltel.net)
Date: 03/29/05


Date: Tue, 29 Mar 2005 02:57:06 -0500

I'm trying to make a five second timer based on what little code I know. I don't
understand why my timer is not updating for the next iteration.

Thanx again for your help and instruction,

// Example for 5 second timer

#include <iostream>
#include <ctime>

int main()
{
   using std::cout;
   using std::cin;

   time_t timerStart = ((time (0)) +5); // Add 5 sec to current time
   time_t timerFinish = time (0); // Get current time

   for ( ; timerStart >= timerFinish ; ) // Compare the two values loop
      {
      cout << ".";
      time_t timerFinish = time (0); // Update timerFinish for next iteration
      }
   cout << "Five seconds have passed.\n";
   return 0;
}