C library function - tmpfile()
2015-11-30 20:32
288 查看
Description
The C library function FILE *tmpfile(void) creates a temporary file in binary update mode (wb+). The temporary file created is automatically deleted when the stream is closed (fclose) or when the program terminates.Declaration
Following is the declaration for tmpfile() function.
FILE *tmpfile(void)
Parameters
NA
Return Value
If successful, the function returns a stream pointer to the temporary file created. If the file cannot be created, then NULL is returned.
Example
The following example shows the usage of tmpfile() function.
#include <stdio.h>
int main ()
{
FILE *fp;
fp = tmpfile();
printf("Temporary file created\n");
/* you can use tmp file here */
fclose(fp);
return(0);
}
Let us compile and run the above program to create a temporary file in /tmp folder but once your program is out, it will be deleted automatically and the program will produce the following result −
Temporary file created
相关文章推荐
- NYOJ 108士兵杀敌(一)
- 真的有一生顺遂没有挫折苦难的人生吗?
- 有用的dede表单代码
- 《算法竞赛入门经典2ndEdition 》例题3-6 环状序列(Circular Sequence, Uva1584)
- 十一月英语总结——英语需要每天都保持热情
- sql.Date与util.Date日期格式化和转换
- 汉诺塔IV
- 找出无向图汇总的相连要素
- xcode常见报错调试【转载】
- 关于java中的值传递问题
- Bootstrap历练实例:简单的可折叠
- 子类和父类构造方法的执行先后问题
- 以蓝牙开发的视觉解读微信Airsync协议
- https 双向认证开发实践
- 使用appcompat这个包之后出现Attribute "height" has already been defined这个问题。
- Docker:使用pipework配置docker网络
- 实时软件控制设计第一次作业
- c#事件(续委托之后)
- 毕达哥拉斯三元组(勾股数组)poj1305
- [Javascript] Advanced Reduce: Additional Reducer Arguments