JASON
JASON

Reputation: 7491

invalid conversion from time_t to const time_t*

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.

Upvotes: 2

Views: 8016

Answers (2)

JASON
JASON

Reputation: 7491

localtime requires an argument of "time_t*" which is a pointer. So you have to put the & there.

Upvotes: 2

geekosaur
geekosaur

Reputation: 61379

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?)

Upvotes: 4

Related Questions