title: Stopwatch program in standard C
body: <p>I'm trying to create a program of a stopwatch using this Standard C-Free 5.0. Here's what I've got so far:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;time.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;windows.h&gt;
  
  char button;
  int minutes=0, seconds=0, millisec=0;
  
  int main(void)
  {
      while(1)
      {
          reset:
          button = '\0';
          int minutes=0, seconds=0, millisec=0;
          printf("  %d :  %d :  %d ", minutes, seconds, millisec);
          system("cls");
          if(button == 'a')
          {
              while(1)
              {
                  cont:
                  button = '\0';
                  Sleep(10);
                  millisec++;
                  if(millisec == 100)
                  {
                      millisec = 0;
                      seconds++;
                      if(seconds == 60)
                      {
                          seconds = 0;
                          minutes++;
                      }
                  }
                  printf("  %d :  %d :  %d ", minutes, seconds, millisec);
                  system("cls");
                  if(button == 's')
                  {
                      while(1)
                      {
                          button = '\0';
                          printf("  %d :  %d :  %d ", minutes, seconds, millisec);
                          system("cls");
                          if(button == 'a')
                          {
                              goto cont;
                          }
                          if(button == 'd')
                          {
                              goto reset;
                          }
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>I'm trying to start the stopwatch with a pressed of button 'a' but it wouldn't work. Using scanf() will pause the whole program. Is there a way to detect a button being pressed and continue the stopwatch program? I mean without pausing the program especially the pressing 's' to stop and pressing 'a' again to continue, while displaying the timer at all times.</p>