C/C++ Programmer's Guide (G06.25+)
Using the C Run-Time Library
HP C/C++ Programmer’s Guide for NonStop Systems—429301-008
4-5
ANSI-Model I/O
When you characterize a process as a binary file, each I/O request is an interprocess
message. Consequently, when you perform binary interprocess communication, you
should use the direct I/O functions that transfer blocks of data, not single characters.
When you characterize a process as a text file, each line is an interprocess message.
Because these messages do not physically contain newline characters, the run-time
library automatically adds them on input and removes them on output.
Terminals
When accessing a terminal, you can use either the text or the binary logical type.
When you characterize a terminal as a text file, data is normally line-buffered. As a
result, input from the terminal is not available until the terminal user presses the Return
key.
When you characterize a terminal as a binary file, no buffering occurs.
If you open a terminal for alternate-model I/O as a binary file, an ambiguity arises when
you read an empty line because the return value is zero (which normally indicates the
end of the line). In this case, the alternate-model I/O functions set errno to the value 1
to indicate the end of the file.
$RECEIVE
When you are accessing $RECEIVE, HP recommends that you use Guardian system
procedures, rather than the ANSI or alternate I/O C functions, for:
•
Performing interprocess communication
•
Opening $RECEIVE and reading or replying to system messages
ANSI-Model I/O
As mentioned earlier, the ANSI-model I/O functions use FILE pointers to identify files.
To create such a pointer, you make a declaration of the form:
FILE identifier;
The functions that open a physical file for ANSI-model I/O return a FILE pointer that
denotes the newly opened file. From this point on, you use that FILE pointer to direct
I/O requests to the physical file.
FILE pointers point to structures that are internal to the run-time library and contain
various kinds of information regarding the file and its status. Several of the ANSI-model
I/O functions offer access to various members of a FILE structure. These members
include the file-position indicator and the file-error indicator.