小编und*_*dog的帖子

如何在没有头文件的情况下调用像 time() 这样的 C 函数?

根据我检查的文档,time_t time(time_t *seconds)<time.h>头文件下声明。然而,当我运行这段代码时:

#include<stdio.h>
#include<stdlib.h>
int main()
{
    srand(time(NULL));
    printf("%d",rand());
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

不包括<time.h>,它工作正常,或者至少工作。怎么会这样?

c header-files forward-declaration function-declaration c-header

2
推荐指数
1
解决办法
86
查看次数