How do I cast a time_t value to int, correctly? :confused:
Printable View
How do I cast a time_t value to int, correctly? :confused:
static_cast<type> object
or.. will casting be enough?
Or do I need to call something like a convert-function? :confused:
The Microsoft libraries use a long int for time_t, so this cast ought not to cause problems.Code:time_t the_time; // declare a time_t variable
long int x; // declare a long int
the_time = time(0); // initialize the time_t variable with the system time
x = static_cast<int> the_time; // case the time_t variable to a long int