How are file descriptors and file pointers related? When is it appropriate to use each?
How are file descriptors and file pointers related? When is it appropriate to use
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.
You pass “naked” file descriptors to actual Unix calls, such as
read(),write()and so on.A
FILEpointer is a C standard library-level construct, used to represent a file. TheFILEwraps the file descriptor, and adds buffering and other features to make I/O easier.You pass
FILEpointers to standard C functions such asfread()andfwrite().