home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / elem-c.zip / DOSTIME.C < prev    next >
C/C++ Source or Header  |  1985-05-18  |  2KB  |  44 lines

  1. /********************************************************
  2.  *  THIS FUNCTION DOES A CALL TO THE MS-DOS OPERATING   *
  3.  *  SYSTEM AND RETURNS THE TIME.  YOU SHOULD PASS A 11  *
  4.  *  CHARACTER ARRAY ADDRESS TO THE FUNCTION IN  WHICH            *
  5.  *  THE TIME WILL BE PLACED UPON RETURN.  THE CALL IS   *
  6.  *  AS FOLLOWS.                                                                                                                                                                    *
  7.  *                char time[11];                                                                                                *
  8.  *                     dostime(time);                                                                                                *
  9.  *  TIME WILL HAVE THE SYSTEM TIME IN IT IN THE FORM    *
  10.  *                HH:MM:SS:HH                           *
  11.  *  HAVE FUN AND GOOD LUCK                              *
  12.  *                                                      *
  13.  *                LYNN LONG                             *
  14.  *                TULSA IBBS C-SIG                      *
  15.  *                1200 BAUD, 24 HOURS                   *
  16.  *                SUBSCRIPTION BBS                      *
  17.  *                918-749-0718                          *
  18.  ********************************************************/
  19.  
  20. #include <dos.h>
  21. dostime(time)
  22. char time[];
  23. {
  24.     char hr[3],
  25.          mm[3],
  26.          ss[3],
  27.          hh[3]; 
  28.     struct HREG TREG;
  29.     TREG.ah=0x2c;
  30.     intdos(&TREG,&TREG);
  31.      stcu_d(hr,TREG.ch,3);
  32.     stcu_d(mm,TREG.cl,3);
  33.     stcu_d(ss,TREG.dh,3);
  34.     stcu_d(hh,TREG.dl,3);
  35.     strcpy(time,hr);
  36.     strcat(time,":");
  37.     strcat(time,mm);
  38.     strcat(time,":");
  39.     strcat(time,ss);
  40.     strcat(time,":");
  41.     strcat(time,hh);
  42.  
  43. }