flush清空输入输出流
2024-10-07 15:23:26
#include <string.h> #include <stdio.h> #include <conio.h> #include <io.h> void flush(FILE *stream); int main(void) { FILE *stream; char msg[] = "This is a test"; /* create a file */ stream = fopen("DUMMY.FIL", "w"); /* write some data to the file */ fwrite(msg, strlen(msg), , stream); printf("Press any key to flush DUMMY.FIL:"); getch(); /* flush the data to DUMMY.FIL without closing it */ flush(stream); printf("\nFile was flushed, Press any key to quit:"); getch(); ; } void flush(FILE *stream) { int duphandle; /* flush the stream's internal buffer */ fflush(stream); /* make a duplicate file handle */ duphandle = dup(fileno(stream)); /* close the duplicate handle to flush the DOS buffer */ close(duphandle); } #include <stdio.h> #include <stdlib.h> int main(void){ FILE *fp; if((fp=fopen("test", "rb"))==NULL) { printf("Cannot open file.\n"); exit(); } char ch = 'C'; int i; ; i<; i++) { fwrite(ch, , fp); fflush(fp); } fclose(fp); ; }
最新文章
- 腾讯QQ你的缓存策略应该改下了
- FTP多任务下载实现类
- 辐射4 中文武器命名方法, 不用winhex, 直接游戏内操作
- paip.中文 分词 -- 同义词大全整理
- kafka监控之KafkaOffsetMonitor
- Controlling How NSThread and NSRunLoop Exit
- Android学习四、Android中的Adapter
- Android取得屏幕的高度和宽度
- 原生应用native、Web应用、混合应用hybrid:3者的优缺点解析
- 爬虫关于ip管理池的应用
- SqlCommandBuilder类是如何构建T-Sql语句
- Git详细教程(3)---结合gitHub使用
- 浅谈python模块的导入操作
- Kali 安装 VMwaretools 时 “没有足够可有空间提取xxxxxx”
- foreach 使用 引用&; $value . 使用 unset($value)
- Flask-WTF表单的使用
- zTree重命名节点时,操作的那个dom(类似input框那个)怎么写
- windows下《Go Web编程》之Go工作空间
- DevExpress ChartControl控件实现图表【转】
- transparent 透明效果