How is the result struct of localtime allocated in C?

后端 未结 6 1062
爱一瞬间的悲伤
爱一瞬间的悲伤 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:13

    Actually localtime usually returns the address of a static object. I suspect it looks like this:

    struct tm *
    localtime(const time_t *timer)
    {
        static struct tm tm;
    
        /* Magic. */
    
        return &tm;
    }
    

提交回复
热议问题