Doesn't this code example have a bug ???

I was looking at the code example for mktime here

http://www.cplusplus.com/reference/clibrary/ctime/mktime/

and am not sure this makes sense ....

the variable timeinfo is declared as a pointer to struct tm, and then used.

Is that valid ?

Should somethig like

timeinfo = new tm;

be done so as to reserve space for the structure ?



I think the localtime() docs can explain.
http://www.cplusplus.com/reference/clibrary/ctime/localtime/

Return Value
A pointer to a tm structure with the time information filled in.

This structure is statically allocated and shared by the functions gmtime and localtime.

-Albatross
Last edited on
Topic archived. No new replies allowed.