清除文件缓冲区,文件以写方式打开时将缓冲区内容写入文件
没有你后面说的那个。
例子:
#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";
stream = fopen("DUMMY.FIL", "w");
fwrite(msg, strlen(msg), 1, stream);
clrscr();
printf("Press any key to flush DUMMY.FIL:");
getch();
flush(stream);
printf("
File was flushed, Press any key to quit:");
getch();
return 0;
}
void flush(FILE *stream)
{
int duphandle;
fflush(stream);
duphandle = dup(fileno(stream));
close(duphandle);
}
◆◆
评论读取中....
请登录后再发表评论!
◆◆
修改失败,请稍后尝试