If you read data from a binary stream processed one record at a time, and the product of size and count (parameters of fread()) is greater than the record length, then only the data in the current record is read into the buffer. The fread() function returns a value indicating that there is less data in the buffer than was specified.
If the product of size and count is less than the actual record length, errno is set to ETRUNC to indicate that there is data in the record that was not copied into the buffer.
This figure illustrates how only the current record is read into the buffer, when the product of size and count is greater than the record length.
Figure 100. Reading from a Binary Stream File a Record at a Time
Only fread() function is valid for reading binary stream files opened for record-at-a-time processing. All other input and positioning functions fail, and errno is set to ERECIO.
Example:
The following example illustrates how to read a binary stream a record at a time.
Figure 101. ILE C Source to Read from a Binary Stream File by Record
|
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.