Can any body tell me the difference between file descriptor and filepointer in C on linux? and when to use what?

Recommended Answers

All 3 Replies

The descriptor is what is returned by open() and passed to close(), read(), write() etc.
It is what identifies the open file.

The filepointer is the location within the file where the next read/write operation will take place.
You can modify it by using say lseek().

Thanx.. A alot for u r quick reply..

File pointer:
1.It is high level interface
2.Passed to fread() and fwrite() functions
3.Includes buffering,error indication and EOF detection,etc.
4.Provides higher portability and effeciency.

File descriptor:
1.Low/Kernel level handler
2.passe to read() and write() of UNIX System Calls
3.Doesn't include buffering and such features
4.Less portable and lacks effeciency

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.