我有一个通过调用fopen()返回的FILE *。我需要从它获取一个文件描述符,以便在它上进行像fsync(fd)这样的调用。从文件指针获取文件描述符的函数是什么?
发布于 2021-12-06 02:51:44
  fd = _fileno(fp);  // Probably the best way
       fd = fp->_file;     // direct from the FILE structure, member 
   
    typedef struct _iobuf  {
       char*   _ptr;
       int     _cnt;
       char*   _base;
       int     _flag;
       int     _file;
       int     _charbuf;
       int     _bufsiz;
       char*   _tmpfname; } FILE;https://stackoverflow.com/questions/3167298
复制相似问题