C/C++ Programmer's Guide (G06.27+, H06.03+)

Table Of Contents
Using the C Run-Time Library
HP C/C++ Programmer’s Guide for NonStop Systems429301-010
4-3
Logical File Types
functions. To find out how to access these procedures, see Section 3, Interfacing to
Guardian Procedures and OSS Functions.
Logical File Types
Regardless of the file-reference model you use, specify the logical file type of a
physical file when you open the physical file. When selecting logical type to use,
consider two factors:
1. The logical types best matches the way you want to interpret the data in the
physical file
2. Logical type chosen in Step 1 is available for the given physical file type
The next two subsections describe how the two logical file types interpret and buffer
data.
Binary-Type Logical Files
The C run-time library interprets a binary-type logical file as a sequence of arbitrary
byte values. It does not translate data on input or output. Consequently, control the
structure, content, and interpretation of a binary-type logical file.
Text-Type Logical Files
The C run-time library interprets a text-type logical file as a sequence of lines
containing ASCII text. Terminating each line of text is a newline character \n. In
addition, tab characters are converted to an appropriate number of spaces.
Both of the file-reference models perform line buffering of text files. However, both
models enable you to disable this buffering. In the ANSI model, the setnbuf()
function provides this service; in the alternate model, the fcntl() function does it.
Line buffering implies that data is buffered until a newline is transferred. However, the
C run-time library also flushes the buffer when:
the buffer becomes full. The maximum buffer sizes are listed in Table 4-1 on
page 4-4.
you explicitly flush the buffer (using fflush() or fcntl()).
you make a call to fclose() or exit().
you make an input request of a nondisk file without flushing a series of output
requests (by sending a newline or flushing the buffer).