Whats is difference between file descriptor and file pointer?
After having 1 year of experience in c programming when someone has asked this to me i was surprised that why i dont know this…!!
Well when i will going to interview someone in someday this would be my 1st question to him/her…!!!
File Descriptor :
“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.”
int fd; fd = open(path, O_CREAT | O_RDONLY, 0644); close(fd); |
This way you are using that is file-descriptor. In short, file-descriptor is
- Low/Kernel level handler
- passe to read() and write() of UNIX System Calls
- Doesn’t include buffering and such features
- Less portable and lacks efficiency
- It’s some what OS specific so its not part of standard c programming language.
File Pointer :
“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.”
FILE *fp = fopen("mr32.txr","r"); |
When you write this then you are using file pointer. file pointer is
- It is high level interface
- Passed to fread() and fwrite() functions
- Includes buffering,error indication and EOF detection,etc.
- Provides higher portability and efficiency.
- It’s part of standard c programming language.
see also
Convert file descriptor to file pointer | Convert file pointer to file descriptor in Linux by C programming
You may like to read this also....
1 Comment to “Whats is difference between file descriptor and file pointer?”
Post comment
Search in this website
our sponsors
latest comments
- venkat on C programming interview questions and answers for freshers
- Ankur on How to configure mail from localhost ( wamp ) using PHP?
- ergVFyd on Huffman Encoding Using Linked List with Source Code
- karthick on how can I write applications in C or C++ for Android?
- karthick on how can I write applications in C or C++ for Android?
Find us on Facebook
Top Authors
Find us on stackoverflow
Polls
Loading ...
My Bookmarks
- Audio/video Recorder & player application based on MATLAB
- check dependency of your binary
- defination of all standard c programming language function
- Great Question-Answer on c programming
- know what your c code means
- Limition of c programming language
- List of all version of c programming language
- Online c compiler
- php freelancing work
- some more stuff on C programming language
- Volatile Keyword in Embedded System
- Write Android application in c language
[...] Whats is difference between file descriptor and file pointer? [...]