Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!sdd.hp.com!wuarchive!rice!rice!sun-spots-request From: morourk@hubcap.clemson.edu (Michael O'Rourke) Newsgroups: comp.sys.sun Subject: strptime Keywords: Miscellaneous Message-ID: <1990Oct7.231330.4056@rice.edu> Date: 7 Oct 90 21:30:00 GMT Sender: sun-spots-request@rice.edu Organization: Sun-Spots Lines: 38 Approved: Sun-Spots@rice.edu Originator: spots@walhalla.rice.edu X-Sun-Spots-Digest: Volume 9, Issue 339, message 3 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 #include #include 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); }