我需要与Windows上使用C++ iostream相关联的Windows FileHandle。这可能与Windows上与C++ iostream相关联的UNIX文件描述符相同。有人知道怎么找到它吗?谢谢。
发布于 2011-11-13 07:11:26
你看到我的回答了吗,这里:
How do I flush a stdlib output file on win32?
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());
}https://stackoverflow.com/questions/8107588
复制相似问题