- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个 C++ 程序正在写入 Windows 7 上的文件。当我调用 f.flush()
时,NTFS 文件没有变大。有什么办法可以强制刷新文件吗?
最佳答案
你可以看这里:
How do I get the file HANDLE from the fopen FILE structure?
代码如下所示:
FlushFileBuffers((HANDLE) _fileno(_file));
不要忘记在调用 FlusFileBuffers 之前调用 fflush(file)。
对于 std::fstream 和 gnu STL,我在我的 linux box 上检查过,家里没有 window ,但应该与 mingw 一起使用,可能需要一些修改:
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <fstream>
#include <ext/stdio_filebuf.h>
int main(int argc, char *argv[])
{
assert(argc == 2);
std::ifstream f(argv[1]);
assert(!!f);
/*
//cin, cout etc
__gnu_cxx::stdio_filebuf<char> *stdio_buf = dynamic_cast<__gnu_cxx::stdio_filebuf<char> *>(f.rdbuf());
if (stdio_buf != 0) {
printf("your fd is %d\n", stdio_buf->fd());
return EXIT_SUCCESS;
}
*/
std::basic_filebuf<char> *file_buf = dynamic_cast<std::basic_filebuf<char> *>(f.rdbuf());
if (file_buf != 0) {
struct to_get_protected_member : public std::basic_filebuf<char> {
int fd() { return _M_file.fd(); }
};
printf("your fd is %d\n", static_cast<to_get_protected_member *>(file_buf)->fd());
}
printf("what is going on?\n");
return EXIT_FAILURE;
}
关于c++ - 如何在 win32 上刷新 stdlib 输出文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8107436/
我在 Agda 中处理字符串,并且我有它们的向量。我需要检查给定字符串是否出现在向量中(作为检查变量是否自由或绑定(bind)在表达式中的一部分,在我正在做的 PL 理论 wprk 中)。 我仍在寻找
我正在编译大量使用 srand() 和 rand() 的文件,但不包括 stdlib.h。我知道这是不好的做法,但是由于我无法更改正在编译的文件,因此无法在每个文件中插入必要的 include 语句。
我想在我的 Rails 应用程序中使用 Date::ABBR_MONTHS 常量。我在 http://www.ruby-doc.org/stdlib/ 看到了 Ruby stdlib 文档似乎没有这个
昨天我更新了 Android Studio 版本和 Kotlin 插件版本。 Android Studio 版本:3.1.2 Kotlin 版本:1.2.41 当我使用此配置创建 Android 项目
我是使用 CGAL 库的初学者,在组合 CGAL 后,我尝试在 fedora 上运行一个组合映射示例 qt-creator: #include #include #include #includ
Android Studio 2.3.3; Kotlin 插件:1.1.4; Kotlin 编译器:Kotlin 到 JVM:1.6。 Android Studio > 新建项目 > 在项目操作中配置
我有使用 opengl 和 CGAL 的 c++ qt 项目,但我有以下错误: /usr/include/c++/7/cstdlib:75:15: fatal error: stdlib.h: No
我知道的一件事可能不是真的,那就是 T应该是可复制构造的,即T应该有一个可访问的复制构造函数。 但是,是否还有其他要求,例如copy assignable? 作为补充,我记得 Effective ST
此代码片段主要来自 qsort 的手册页。 int cmp(const void *p1, const void *p2) { char s1 = *(*(char * const *)p1);
在现代 C++ 中,标准库是否提供类型列表模板? int main() { using int_types = type_list; std::cout ::value ::type)
我一直在想,C++ 中的设计决策是否有任何理由不为任何标准库容器提供纯抽象类? 我很欣赏 hash_map 后来来自 stdext 命名空间,但共享一个非常相似的接口(interface)。如果我后来
这个问题在这里已经有了答案: What is the use of _start() in C? (4 个答案) 关闭 6 年前。 采用以下 C 程序: int main(){} 它没有使用 C 标
关注此blog post我试图编译 stdlib.so 以将其他代码与其链接。不幸的是,stdlib.so 本身是一个动态链接的二进制文件: # ldd /usr/local/go/pkg/linux
作为一个 puppet 新手,我有一个问题,包括 stdlib 插件 我想使用 stdlib 的 file_line,因此我尝试包含 stdlib 并调用它 class service_mon {
我正在尝试在我创建的类中使用 stdlib 堆栈,但我在动态创建它时遇到问题。 这是我的头文件“matcher.h”中的相关代码: private: stack opens;
我已经更新了我的一个非常旧的项目(XCODE 4.5.1 baseSDK iOS6)并且由于某种原因我得到了上面的错误。 它只为 iOS5+ 编译但不适用于 iOS 4.3 ? 有什么想法吗? 最佳答
我有一个使用标准库 fopen/fclose 函数实现的文件 IO 接口(interface),它运行良好,直到我们不得不将其更改为同步实现以防止数据丢失(一种情况)。所以我用系统调用(open()/
这个问题在这里已经有了答案: 关闭 11 年前。 Possible Duplicate: How does system() exactly work in linux? 出于好奇,我想知道 sys
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 7 年前。 Improve
已关闭。这个问题是 not reproducible or was caused by typos 。目前不接受答案。 这个问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-top
我是一名优秀的程序员,十分优秀!