home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_03_05 / 3n05068a < prev    next >
Text File  |  1992-03-17  |  801b  |  34 lines

  1. /*
  2.  *   daytime.c - a demonstration program to read and
  3.  *               interpret the DOS CLOCK$ driver
  4.  *   Written by M. L. Lesser, 11/7/91, for Borland C
  5.  *               (Use pragma to pack structures
  6.  *               if compiling with MS C)
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include <io.h>
  11. #include <fcntl.h>
  12. #include <sys\stat.h>
  13.  
  14. int   handle;
  15. typedef unsigned char byte;
  16.  
  17. struct {
  18.     int days;
  19.     byte minutes;
  20.     byte hours;
  21.     byte hundsecs;
  22.     byte seconds;
  23. } today;
  24.  
  25. void main()
  26. {
  27.     handle = open("CLOCK$",O_RDONLY | O_BINARY);
  28.     read(handle,&today,6);
  29.     close(handle);
  30.     printf("There have been %d days since 1-1-80\n",today.days);
  31.     printf("The time of day is %02d:%02d:%02d.%02d\n",
  32.     today.hours,today.minutes,today.seconds,today.hundsecs);
  33. }
  34.