www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/14/02:46:46

From: michael DOT mauch AT gmx DOT de (Michael Mauch)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: time.h
Date: Thu, 13 Aug 1998 13:42:45 +0200
Organization: Gerhard-Mercator-Universitaet -GH- Duisburg
Lines: 30
Message-ID: <6qujfe$g7n$1@news-hrz.uni-duisburg.de>
References: <35D1FE59 DOT CE391D41 AT nettally DOT com>
NNTP-Posting-Host: ppp82.uni-duisburg.de
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Wed, 12 Aug 1998 16:43:05 -0400, Bruce Ferguson
<symbiatu AT nettally DOT com> wrote:

> int tm_year;
> printf("%d",tm_year);

> Well, much to my chagrin the value printed for the number of years since
> 1900 was 84.  My system clock is correct it says Wednesday, August 12,
> 1998, 4:41 pm.  But this program is telling me that the years since 1900
> is 84.  Last I checked it was 1998. So what is it I am doing wrong..  Or
> what is it that is wrong?

You are using an uninitialized variable. It's much the same if you
wrote:

int PleaseDearComputerWhatsTheTime;
printf("%d",PleaseDearComputerWhatsTheTime);

Please see the example in the libc reference for the gmtime() function.
Use localtime() instead of gmtime() to get your local time. Add a line

printf("%d",t.tm_year);

so that's what you wanted to do. 

But please get yourself a good C book and ask such general
non-DJGPP-related C questions in comp.lang.c better.

Regards...
		Michael

- Raw text -


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