跳到主要内容

fflush

注意

这个函数是在omp v1.1.0.2612中添加的,在以前的版本中不起作用!

注意

这个$函数以小写字母开头。

描述

将文件刷入磁盘(确保所有写入完成)。实际调用 flength 函数实现,因为该函数需要强制刷新以确保准确性。

名称描述
File:handle文件句柄(由 fopen 返回)。

返回值

true - 函数执行成功。

false - 函数执行失败(无效的文件句柄)。

示例

// 以"仅追加"模式打开"file.txt"
new File:handle = fopen("file.txt", io_append);

// 检查文件是否成功打开
if (handle)
{
// 成功

// 追加文本"This is a text.\r\n"
fwrite(handle, "This is a text.\r\n");

fflush(handle);

// 关闭文件
fclose(handle);
}
else
{
// 错误
print("文件 \"file.txt\" 不存在或无法打开。");
}

相关函数