Hello everyone,
In MSDN for time function,
time_t time(
time_t *timer
);
http://msdn2.microsoft.com/en-us/library/1f4c8f33(VS.80).aspx
the return value of time is time_t, but in the Return Value section, it
mentioned,
Return the time as seconds elapsed since midnight, January 1, 1970. There is
no error return.
So, I am wondering whether time_t could be represented as elapsed number of
seconds correctly and safely -- no data lost if we convert return value to
unsigned long?
Like,
unsigned long second = time (NULL);
thanks in advance,
George
David Lowndes - 29 Oct 2007 11:15 GMT
>In MSDN for time function,
>
[quoted text clipped - 13 lines]
>seconds correctly and safely -- no data lost if we convert return value to
>unsigned long?
George,
time_t is (in later compilers) defined as a 64-bit value (with the
option of being a 32-bit value for backward compatibility). It's best
if you play by the rules and use it with appropriate functions such as
difftime.
Dave