INF: Appending to CTRL+Z Terminated File with Fopen()

ID Number: Q29852

4.00 5.00 5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

When appending to a stream file that is terminated with the

end-of-file (EOF) marker CTRL+Z (CONTROL+Z or the ASCII code 1A

hexadecimal), use the "a+" type with the fopen() function. The "+" in

the type "a+" allows for both writing and reading.

More Information:

If you use the "a" type with fopen() for appending in write-only mode,

the EOF marker will not be removed. Subsequently, using the MS-DOS

TYPE command on the file will only display data up to the original EOF

marker, and will not display appended data.

The fopen() type "a+" will allow you to remove the EOF marker from the

file before appending, so that appended data can then be displayed

with the TYPE command.

The "a+" is required because the operating system must be permitted to

read the file to locate the EOF marker and overwrite it with appended

data. Using the "a" type prohibits reading the file, so the operating

system is unable to find the EOF marker for overwriting, and instead

the appended data is written after the EOF marker.

Additional reference words: 5.0 5.00 5.1 5.10 6.0 6.00 6.0a 6.00a

6.0ax 6.00ax 7.0 7.00