How is the result struct of localtime allocated in C?

后端 未结 6 1064
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 04:47

I was playing with the time.h file in C that helps us with time/day functions.

I came across:

struct tm * _Cdecl localtime(const time_t          


        
6条回答
  •  春和景丽
    2020-11-30 05:07

    The man page says:

    The return value points to a statically allocated struct which might be overwritten by subsequent calls to any of the date and time functions.

    Also:

    The localtime_r() function does the same, but stores the data in a user-supplied struct. It need not set tzname, timezone, and daylight.

提交回复
热议问题