title: Implementing a timer in c++
body: <p>I am currently making a game in c++. I have below a timer function:</p>
  
  <pre><code>void timer(int &amp;s , int &amp;m , bool a)
  {
     while (a)
     {
        Sleep(1000);
        if (s%60)
          m+=1;
        s+=1;
     }
  }
  </code></pre>
  
  <p>Here is the function for the game:</p>
  
  <pre><code>void game()
  {
     int s = 0 , m = 0;
     char a[]="Computers";
     char b[10];
     timer(s,m,true);
     while (strcmpi(a,b)!=0)
     {
        cout&lt;&lt;"Guess the word:";
        gets(b);
     }
     timer(s,m,false);
     cout&lt;&lt;"You got it correct!\n";
     cout&lt;&lt;"Time taken : "&lt;&lt;m&lt;&lt;':'&lt;&lt;s&lt;&lt;endl;
  }
  </code></pre>
  
  <p>When I run the program , nothing happens. I am guessing the timer is running and not allowing the while loop in the <code>game()</code> to get executed. </p>
  
  <p>So basically I am trying to find out the time the user takes to guess the word correctly.</p>
  
  <p>How can I overcome this problem? </p>
  
  <p>Thanks in advance :)</p>