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.
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?”
Search in this website
- sagar on List of all standard version of c language
- Mohit Dhukia on How to access/unblock songs.pk in india?
- shinto peter on How to configure mail from localhost ( wamp ) using PHP?
- tammylleanne on Implementation limitation of c programming language
- Deepak on How to access/unblock songs.pk in india?
Find us on Facebook
Find us on stackoverflow
- 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