我想知道是否可以在FILE
不关闭底层文件描述符的情况下释放包装器:
void stream_function( int fd ) {
FILE * stream = fdopen( fd, "r");
// Read from stream with fread / fscanf
// then close the buffered stream object with the mythical
// xclose( stream ) function, leaving the fd intact.
xclose( stream );
}
int main( ) {
int fd = open("filename" , flags);
stream_function( fd );
// Continue to use fd
close( fd );
}