Blocked I/O

Blocked I/O is an extension to the ISO standard. For files opened in block format, z/OS® XL C/C++ reads and writes one block at a time. If you try to write more data to a block than the block can hold, the data is truncated. For blocked I/O, z/OS XL C/C++ allows only the use of fread() and fwrite() to read and write to files. Any other functions (such as fprintf(), fscanf(), getc(), and putc()) will fail. Blocks do not change size when you update them. If the new block has fewer bytes than the original block, the new data fills the first n bytes, where n is the number of bytes of the new data. The block will remain the same size, and the old bytes (those after n) are left unchanged. A subsequent update begins at the next boundary. For example, if you have the string "abcdefgh":

graphic

and you overwrite it with the string "1234", the block will look like this:

graphic

z/OS XL C/C++ blocked I/O is binary. That is, it does not interpret any of the data in a block file and therefore does not recognize control characters.

The fflush() function has no effect for blocked I/O files.