Record I/O

Record I/O is an extension to the ISO standard. For files opened in record format, z/OS® XL C/C++ reads and writes one record at a time. If you try to write more data to a record than the record can hold, the data is truncated. For record 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. For record-oriented files, records do not change size when you update them. If the new record has fewer bytes than the original record, the new data fills the first n bytes, where n is the number of bytes of the new data. The record 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 record will look like this:

graphic

z/OS XL C/C++ record I/O is binary. That is, it does not interpret any of the data in a record file and therefore does not recognize control characters. The only exception is for file categories that do not support records, such as the UNIX file system (also known as POSIX I/O). For these files, z/OS XL C/C++ uses new-line characters as record boundaries.