title: One-Second Timer
body: <p>I need a timer that does X every second.
  I made this, however it doesn't print anything until the program is terminated, I find that weird.
  It prints everything after three seconds if you put three as the counter, and 100 if you chose that.</p>
  
  <p>How do make it print every second and not all at once at termination?</p>
  
  <pre><code>int main()
  {
      using namespace std;
      //Number to count down from
      int counter = 10;
      //When changed, a second has passed
      int second = (unsigned)time(NULL);
      //If not equal to each other, counter is printed
      int second_timer = second;
      while (counter &gt; 0) {
          second = (unsigned)time(NULL);
          while (second != second_timer) {
              //Do something
              cout &lt;&lt; counter-- &lt;&lt; ", ";
              //New value is assigned to match the current second
              second_timer = second;
          }
      }
      cout &lt;&lt; "0" &lt;&lt; endl;
      return 0;
  }
  </code></pre>