Saturday, October 4, 2008

What is a file pointer?

The ISO C standard I/O functions use file pointer instead of file descriptor.

File pointer is the address of a FILE structure which in turn contains the file descriptor number. The FILE structure also contains the buffer used in buffered I/O.  Data will be written out from the buffer to the destination devices when the buffer is filled up (for disk I/O) or when the new line character is encountered (for terminal I/O).  The I/O subsystem performs the write using file descriptor.

The fflush call force-writes the buffer out immediately.

No comments: