Date: Wed, 17 Nov 1999 15:01:24 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Myron Seto cc: djgpp AT delorie DOT com Subject: Re: Question(newbie): strptime alternative In-Reply-To: <80tp1j$f56$1@nnrp1.deja.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Wed, 17 Nov 1999, Myron Seto wrote: > const long secondsperday = (24 * 60 * 60); [snip] > printf("%d\n", (mktime(&second) - mktime(&first)) / secondsperday); This is non-portable: you are assuming that time_t is in seconds. While this is true in many libraries, it is not a good idea to rely on this. Use the difftime function instead. > struct tm first, second; > strptime("10/1/1972", "%x", &first) > strptime("12/10/1999", "%x", &second) > > for example, but djgpp compiler does not have strptime. Can someone > please suggest an alternative? One alternative is to fill the fields of struct tm variables directly, or by using sscanf (if you must to begin with a string).