strptime

Michael O'Rourke morourk at hubcap.clemson.edu
Mon Oct 8 07:30:00 AEST 1990


I am attempting to use strptime for the first time, but without any luck.
It is getting fed a string with a date in the format of "08/31/90" but it
DOESN'T work. 

Can someone take a look at the following code and tell me if i am doing
something stupid?  As far as i can tell it is okay. The problem is that
the variable tm_time does not get filled in properly so the timegm call
returns -1.

Michael O'Rourke
Clemson University (Graduate Student)

>>> Included Code <<<

#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>

main()
{
time_t Time;
struct tm tm_time, *tm_ptr;
char buffer[50];
int err;

	Time = time(NULL);
	printf("%ld\n",Time);

	tm_ptr = gmtime(&Time);

	err = strftime(buffer,50,"%D",tm_ptr);
	printf("%d : %s\n",err,buffer);

->	strptime(buffer,"%D", &tm_time);

	Time = timegm(&tm_time);
	printf("%ld\n",Time);
}	



More information about the Comp.sys.sun mailing list