title: How do I create a timer using the time.h library?
body: <p>This is not a homework, it's more of a challenge from our prof but I'll be tagging it as one nonetheless.</p>
  
  <p>The problem is to create a typing game that has 3 levels with matching difficulty, different time limits (in seconds) and scores. Now I don't have any problems with the program itself, what I'm having problem is implementing the timer, that should be OS independent (I assume, since the only hint says it's time.h ). What I did is wrong, for it's only a rough guess from what I read about the time.h, it's also ugly code:</p>
  
  <pre><code>time_t start;
  int timer = time(&amp;start);
  ...
  time_t current;
  for(ctr=0;ctr&lt;10;ctr++)
  {
      ...
      if(time(&amp;current) == (timer+40))
        {    
             break;
        }
      ...
  }
  </code></pre>
  
  <p>Works sometimes but doesn't most of the time since it's only a rough guess. Any suggestions would be appreciated.</p>