什么是文件描述符和文件指针之间的区别? [英] What's the difference between a file descriptor and file pointer?
问题描述
我想知道一个文件描述符和文件指针之间的差。
I want to know the difference between a file descriptor and file pointer.
此外,在什么情况下你会使用一个,而不是其他?
Also, in what scenario would you use one instead of the other?
推荐答案
一个文件描述符用来识别一个打开的文件在内核级别低级别的整数的把手(或插座,或其他),在Linux和其他类Unix系统。
A file descriptor is a low-level integer "handle" used to identify an opened file (or socket, or whatever) at the kernel level, in Linux and other Unix-like systems.
您通过裸文件描述符实际的Unix调用,如 阅读()一>
, 的write()
等。
You pass "naked" file descriptors to actual Unix calls, such as read()
, write()
and so on.
A 文件
指针是C标准库层次结构,用于重新present的文件。在文件
包装文件描述符,并增加了缓冲等功能,使I / O更容易。
A FILE
pointer is a C standard library-level construct, used to represent a file. The FILE
wraps the file descriptor, and adds buffering and other features to make I/O easier.
您传递文件
指针标准C函数,如的 FREAD()
和 FWRITE()
。
You pass FILE
pointers to standard C functions such as fread()
and fwrite()
.
这篇关于什么是文件描述符和文件指针之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!