www.delorie.com/archives/browse.cgi   search  
Mail Archives: pgcc/1999/11/09/12:35:56

Message-ID: <3828510F.19D8DBDD@thalamus.wustl.edu>
Date: Tue, 09 Nov 1999 10:51:27 -0600
From: Gijsbert Stoet <stoet AT pcg DOT wustl DOT edu>
X-Mailer: Mozilla 4.61 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
To: pgcc AT delorie DOT com
Subject: ftime function works not under WINDOWS98 implementation
Reply-To: pgcc AT delorie DOT com

Hi,

the ftime function does not work correctly.

/////////////////////////////////////////////////////////////////////////////////////////////

#include <time.h>
#include <sys/timeb.h>

void set_today (char *date)
{
  struct timeb m_tp;
  char day_str[10];
  char month_str[10];
  char year_str[10];

  ftime ( &m_tp );  ///// HERE IS THE FUNCTIONS THAT DOES NOT WORK
CORRECTLY
  strftime ( day_str , 10 , "%d" , localtime( &m_tp.time )  );
  strftime ( month_str , 10 , "%m" , localtime( &m_tp.time )  );
  strftime ( year_str , 10 , "%Y" , localtime( &m_tp.time )  );

  sprintf ( date , "%s - %s - %s" , month_str , day_str , year_str );
///returns formatted date
}

int main ()
{
  char date[10];
  set_today(date);
  printf ( "Date: %s\n" , date);
  return 0;
}
//////////////////////////////////////////////////////////////////////

If I compile this program on my linux gcc, it return the correct date.
On my Microsoft Windows 98 PC wit a PENTIUM III (whenever this matters)
it returns 01-18-1970 !!

Thanks,

Dr. Gijsbert Stoet

Washington University, School of Medicine
Box 8108
660 South Euclid Avenue
Saint Louis, MO 63110
U.S.A.

- Raw text -


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