Mail Archives: djgpp/1998/08/14/02:46:46
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 -