delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/17/00:51:45

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Getting the year straight!!
Date: Thu, 16 Jan 1997 18:51:12 -0800
Organization: Two pounds of chaos and a pinch of salt
Lines: 43
Message-ID: <32DEE920.6120@cs.com>
References: <32DDDB36 DOT 2F00 AT pulsar DOT net>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp106.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Master of Zoul wrote:
> 
> Get the system year.
> 
> I am new to C, so I don't understand the time.h file...  :<
> 
> Plz help me out (do not tell me to look at the time.h file, as I
> mentioned before)

You don't want to look at the header file - it's only for experienced
folks.  :)  Just look in the libc documentation.  For example, type the
following words of wisdom from your DOS prompt (this requires that you
have installed 'v2gnu/txi390b.zip'):

  info libc funct time

You'll be treated to a list of all the time-related functions in DJGPP. 
For a brief example of getting the year, look at the following (tested)
program:

#include <stdio.h>
#include <dos.h>

int main( void )
{
    struct date d;

    getdate( &d );
    printf( "The year is %d.\n", d.da_year );

    return 0;
}

That's it!  The rest of the program is left as an exercise for the
reader.  ;)

-- 
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I      |   mailto:fighteer AT cs DOT com   |
| God's final message to His Creation: | http://www.cs.com/fighteer |
| "We apologize for the inconvenience."| Fight against proprietary  |
|                      - Douglas Adams | software - support the FSF!|
---------------------------------------------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019