简体   繁体   中英

How can I convert a file descriptor (int fd) to a file pointer ( FILE* fp )

I can use CFile to get member m_hFile,how to get the CFile's file descriptor(like File*)?I need to convert file handle to file pointer. Thanks!

To my knowledge CFile doesn't use the FILE * abstraction (it uses the windows ReadFile/WriteFile APIs), however you can use _fdopen to get a FILE * from a file descriptor and _open_osfhandl to get a file descriptor for a HANDLE.

You can also use CStdioFile to use FILE * based file operations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM