time_t raw_time = time(NULL);
tm* current_time = localtime(&raw_time);
I got the answer myself... I totally messed up the warnings. Thanks anyway.
The localtime()
function dates back to when (int)
was 16 bits and passing (long)
on the stack was not widely supported; as such, it was specified to pass (long *)
, which at the time was 16 bits. It's been left as is because changing it would break enormous amounts of code. You'll find that most of the time-related functions do this, since they were the only functions at the time that used (long)
. ( lseek()
came later. Care to guess what non- (long)
-using function it replaced?)
localtime requires an argument of "time_t*" which is a pointer. So you have to put the & there.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.