Mapping the C types of I/O to the byte stream model

Binary
In the byte stream model, files opened in binary mode do not contain any record boundaries. Data is written as is to the file.
Text
The byte stream model does not support ASA. New-lines, carriage returns, and other control characters are written as-is to the file.
Record
If record I/O is supported by the kind of file you are using, z/OS® XL C/C++ simulates it by treating new-line characters as record boundaries. New-lines are not treated as part of the record. A record written out with a new-line inside it is not read back as it was written, because z/OS XL C/C++ treats the new-line as a record boundary instead of data.

Files in z/OS UNIX file system support record I/O, but memory files do not.

As with all other record I/O, you can use only fread() and fwrite() to read from and write to files. Each call to fwrite() inserts a new-line in the byte stream; each call to fread() strips it off. For example, if you use one fwrite() statement to write the string ABC and the next to write DEF, the byte stream will look like this:

graphic
There are no limitations on lengthening and shortening records. If you then rewind the file and write new data into it, z/OS XL C/C++ will replace the old data. For example, if you used the rewind() function on the stream in the previous example and then called fwrite() to place the string 12345 into it, the stream would look like this:
graphic
If you are using files with this model, do not use new-line characters in your output. If you do, they will create extra record boundaries. If you are unsure about the data being written or are writing numeric data, use binary instead of text to avoid writing a byte that has the hex value of a new-line.