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?
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?
fp is a FILE pointer
File pointer:
File descriptor:
based on this link
It's a pointer to a FILE
structure, if that's what you're asking. A file descriptor is an integer. The FILE
structure and its related APIs are part of the C standard. File descriptors and their related functions are not. In practice you can use either set of functions interchangeably, though there are some notable differences in default behaviour here and there. You can read the man pages to figure out which functions take which sort of parameters. On systems that have file descriptors, you can usually use the fdopen(3)
function to get a FILE
structure from an open file descriptor and fileno(3)
to go the other way.
fdopen
creates a new FILE
object (which needs to be closed, and upon closing which the file descriptor is also closed), while fileno
simply returns the existing file descriptor underlying a FILE
. –
Hussite fp is a FILE pointer
File pointer:
File descriptor:
based on this link
FILE
is a struct that contains information about the file, including the file descriptor.
© 2022 - 2024 — McMap. All rights reserved.