home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc_prog / chap04 / timer.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-05  |  829 b   |  29 lines

  1.  
  2. /* TIMER.C -- uses do loop to    */
  3. /*            check elapsed time */
  4.  
  5. #include <time.h>
  6.  
  7. main()
  8. {
  9.     long start, end, /* starting and ending times */
  10.                      /* measured in seconds since */
  11.                      /* Jan. 1, 1970 */
  12.          ltime;      /* used to get val from time function */
  13.     int seconds;     /* elapsed time to be set */
  14.  
  15.     printf("QuickC Egg Timer\n");
  16.     printf("Enter time to set in seconds: ");
  17.     scanf("%d", &seconds);
  18.     start = time(<ime);  /* get system elapsed seconds */
  19.                            /* since 1-1-70 */
  20.     end = start + seconds; /* calculate alarm time */
  21.  
  22.     do
  23.        ;                       /* null statement for loop body */
  24.     while (time(<ime) < end);   /* wait for alarm time  */
  25.  
  26.     printf("Time's Up!\a\a\a\n");
  27. }
  28.  
  29.