coperating-systemfile-descriptorfile-pointer

What is difference between file descriptor and file pointer?


Possible Duplicate:
What's the difference between a file descriptor and file pointer?

If I open file like this:

FILE *fp = fopen("mr32.txr","r");

then fp is file pointer or file descriptor? What is difference between them?


Solution

  • fp is a FILE pointer

    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 efficiency.

    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 efficiency

    based on this link