c 语言函数 fflush()
来源:互联网 发布:js控制span显示隐藏 编辑:程序博客网 时间:2024/05/22 00:52
转载自(http://www.cplusplus.com/reference/clibrary/cstdio/fflush/)
int fflush ( FILE * stream );
Flush stream
If the given stream was open for writing and the last i/o operation was an output operation, any unwritten data in the output buffer is written to the file.If it was open for reading and the last operation was an input operation, the behavior depends on the specific library implementation. In some implementations this causes the input buffer to be cleared, but this is not standard behavior.
If the argument is a null pointer, all open files are flushed.
The stream remains open after this call.
When a file is closed, either because of a call to fclose or because the program terminates, all the buffers associated with it are automatically flushed.
Parameters
- stream
- Pointer to a FILE object that specifies a buffered stream.
Return Value
A zero value indicates success.If an error occurs, EOF is returned and the error indicator is set (see feof).
Example
In files open for update (i.e., open for both reading and writting), the stream shall be flushed after an output operation before performing an input operation. This can be done either by repositioning (fseek, fsetpos, rewind) or by calling explicitly fflush, like in this example:
/* fflush example */#include <stdio.h>char mybuffer[80];int main(){ FILE * pFile; pFile = fopen ("example.txt","r+"); if (pFile == NULL) perror ("Error opening file"); else { fputs ("test",pFile); fflush (pFile); // flushing or repositioning required fgets (mybuffer,80,pFile); puts (mybuffer); fclose (pFile); return 0; }}
- c 语言函数 fflush()
- C语言fflush()函数
- C语言中的fflush函数
- C语言中的fflush函数
- C语言函数随记:fflush()函数
- C语言中fflush函数的使用方法
- C语言中fflush函数的使用方法
- C语言中fflush函数的使用方法
- C语言fflush函数的移植问题
- C语言库函数 fflush
- C语言 -- fflush()
- C语言 -- fflush()
- C fflush()函数
- C语言中的清空输入缓冲区函数fflush()
- C语言第十六篇:fflush函数有什么作用?
- C语言的scanf()函数用法详解 (缓冲区、格式控制、fflush)
- C语言fflush()函数:清空文件缓冲区(或标准输入输出缓冲区)
- C语言fflush()函数:清空文件缓冲区(或标准输入输出缓冲区)
- flex 组件添加鼠标手型
- 词法分析之浮点数分析
- 切分 字符串指针数组(如环境变量) 的两种方法, 数组下标 和 指针
- string类详解
- 水浒中的诗摘头保尾可谓豪气冲天
- c 语言函数 fflush()
- java Comparator用法实现接口Comparator
- 让人相当郁闷的命名问题
- Android:为什么现在google不让结束整个程序,只让结束单个Activity
- 拾回C++ boost
- 如何安全退出已调用多个Activity的Application?
- 宾馆客房管理系统
- 加快软件开发速度,eclipse最常用的快捷键,开发新手必看
- Android的JSON解析