在由 tmpfile() 创建的临时文件上使用 fclose() 是否安全?

Is it safe to use fclose() on a temporary file created by tmpfile()?

根据this documentationtmpfile()创建的临时文件在程序正常退出时关闭并删除。到目前为止,我还没有找到关于在此类文件上使用 fclose() 的任何详细信息。

Is it safe to use fclose() on a temporary file created by tmpfile()?

是,可以关闭。

The tmpfile function creates a temporary binary file that is different from any other existing file and that will automatically be removed when it is closed or at program termination. If the program terminates abnormally, whether an open temporary file is removed is implementation-defined.
C17dr § 7.21.4.3 2