PAUSE
ENCORE5
ENCORE
BOX
ILLUSTRATION
GO
Assume that there is a file file_a on the system disk:
Disk Drive
__________
/ \
/ \
| |
| |
| |
| |
\ /
\ /
``````````
/ File_1 \
| |
| file_a |
| |
| File_Y |
This file may be several thousand bytes long!
The function that treats the information in file_a as text
uses a buffer for reading and writing to this file!
buffer
-----------------
| ------- |
| |
| fscanf(fp,.) |
| |
| : |
| : |
| fprintf(fp,.) |
| : |
| : |
-----------------
function
---->
----->
<----
<-----
The size of the buffer is the size of one
segment block, and it varies from system
to system, usually between 512 and 4096 bytes!
When the program writes the information into file_a
or reads information from the same file, all data
transfer is done through the buffer!
The data is written from the buffer into the file when the buffer is full.
Similarly, the data is read from the file into the buffer when
the data has been exhausted, i.e., when the buffer is empty!
When the data in the file is referred to by size, i.e., as a
binary object, no buffering occurs, but rather the data
transfer is direct between the function and the disk!
-------------------->
<--------------------