I am using the struct timespec
structure and here it is:
struct timespec {
time_t tv_sec; /* Seconds */
long tv_nsec; /* Nanoseconds */
};
Thing is, user will be entering the values for each of these individual members, and i want to put a check a max. value the user can enter.
Can I take the max. value of time_t
as int max value? i.e INT_MAX
for tv_sec
and LONG_MAX
(defined in limits.h) for the tv_nsec
? What will be the minimum acceptable values for both? Is it zero? I guess negative values can't be accepted? Just to add, these values will be using in a timer.
P.S: Where is the typedef for time_t
? Could not find it in time.h.
Since people here are answering how to set the maximum time_t
value, and make further guesswork as to its type, I thought I'd add the c++
way to do it:
#include <limits>
...
time_t maxTime = std::numeric_limits<time_t>::max();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With