| File Pointer
| File Descriptor
|
1. | File pointer is allocated with fopen function call FILE *fp; fp = fopen("sample.txt,"a"); | File descriptor is allocated with open system call int fd = open( filePath, mode ); |
2. | It is generally, use for the application which is doing extensive read or write from a file | It is generally used for the application that do frequently random access of file |
3. | It is a pointer | It is an integer value like 0, 1, 2 |
4. | The file pointer is buffered | The file descriptor is not buffered |
5. | It is highly portable and efficient | It is less portable and efficient in comparison with the file pointer |
6. | It is passed to fread() and fwrite() function | It is passed to read() and write() function |
7. | It is not suitable for inter-process communication | It is suitable for inter-process communication |
8. | Library functions generally use file pointer | System call generally use the file descriptor |
9 | file pointers are data structures. | File descriptors are represented as integer values |
10 | file pointers are used to represent the current position within the file. | File descriptors are used to identify an open file, |
11 | file pointers are used by the application program to read from or write to the file. | File descriptors are used by the operating system to perform operations on the file, |
12 | file pointers can have any value depending on the position within the file. | File descriptors are non-negative integers, |