Mail Archives: pgcc/1999/11/09/12:35:56
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 -