$man tmpfile说
The standard does not specify the directory that tmpfile() will use.
Glibc will try the path prefix P_tmpdir defined in @H_301_8@dio.h>,and if
that fails the directory /tmp.
我使用的是Ubuntu 13.10 x86_64,gcc和libc BTW.
所以当我尝试使用tmpfile()创建临时文件时,我在/ tmp中看不到任何临时文件. (我可以在stdio.h中看到#define P_tmpdir“/ tmp”).这是我使用的代码片段:
@H_301_8@#includedio.h> int main(int argc,char **argv) { FILE *tmp; tmp = tmpfile(); // Where's this file? scanf("%*d"); return 0; }
$./tmpfile
现在,当scanf正在等待下一个(冗余)输入时,我应该能够在/ tmp中看到一个临时文件.但我不能.那么这个tmpfile到底在哪里创建?
最佳答案