title: Creating a clock program
body: <p>Write  a clock program to achieve the following function:
  a) Press any key to start the timer;
  b) Press the 'S' key to start the timer, press the 'E' key to stop the timer or when the time is 00:00:00 o'clock.</p>
  
  <p>Here is what I have so far</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;windows.h&gt;
  #include &lt;conio.h&gt;
  main()
  {
   long int t;
   int flag =0;
   t = 86400;
   printf("press S start, press E stop\n");
   while(1)
   {
    if (kbhit()== 'S' || kbhit() == 's')
     flag =1;
    if (getch() == 'E' || getch() == 'e')
    { flag =0;
     continue;
    }
    if(t &lt;= 0)
     break;
    if(flag == 1)
    {
    t=t-1;
    Sleep(1000);
    printf("%d ",t);
    }
   }
  }
  </code></pre>
  
  <p>Well, I don't really know how to achieve the control function.How can I press 'E' to give the timer stop, and press 'S' give the timer run again.</p>
  
  <p>I am a beginner and cannot get the right program over and over again.  I hope you can help me.  Thanks!</p>