gpt4 book ai didi

c - 我是否需要释放 localtime() 函数返回的指针?

转载 作者:太空狗 更新时间:2023-10-29 15:54:23 30 4
gpt4 key购买 nike

我目前正在阅读有关 time.h 的联机帮助页。我做到了这一点:

time_t now = time(0);
struct tm * local = localtime(&now);

现在我可以尽可能地处理时间,但是如果我有责任free() 变量local,我找不到信息.

最佳答案

引用man page

The four functions asctime(), ctime(), gmtime() and localtime() return a pointer to static data and hence are not thread-safe. [...]

因此,您不需要 free() 返回的指针。

关于c - 我是否需要释放 localtime() 函数返回的指针?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35031647/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com