Mail Archives: djgpp/1999/11/17/08:33:17
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).
- Raw text -