home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / proglc / timeutil.lzh / WAIT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-10  |  730 b   |  32 lines

  1. /*  WAIT.C - A program to wait until the start of the next minute */
  2.  
  3. #include <stdio.h>
  4. #include <dos.h>
  5.  
  6. main()
  7. {
  8.     struct time dostime;
  9.     int   keyscan, oldsec;
  10.  
  11.     gettime(&dostime);
  12.     oldsec = dostime.ti_sec;
  13.  
  14.     printf("\nWaiting for the next whole minute...\n");
  15.     printf("The time is %02d:%02d:%02d", dostime.ti_hour,
  16.                     dostime.ti_min, dostime.ti_sec);
  17.  
  18.     do
  19.         { gettime(&dostime);
  20.             if ( kbhit() != 0)
  21.                 {
  22.                     keyscan = getch();
  23.                     if ( keyscan == 03 ) exit(1);
  24.                 }
  25.             if (oldsec != dostime.ti_sec)
  26.                 { printf("\b\b\b\b\b\b\b\b%02d:%02d:%02d",
  27.                     dostime.ti_hour, dostime.ti_min, dostime.ti_sec);
  28.                     oldsec = dostime.ti_sec;
  29.                 }
  30.     } while (dostime.ti_sec > 0);
  31.     printf("\n");
  32. }