C/C++ Programmer's Guide (G06.25+)
Running and Debugging C and C++ Programs
HP C/C++ Programmer’s Guide for NonStop Systems—429301-008
19-3
The Standard Input, Output, and Error Files
CRE has established its environment and set up shared facilities, it calls a language-
specific initialization function for each language that is represented by a routine in your
program, except TAL and pTAL. Each language-specific initialization function sets up
its data structures and file I/O model for the language that it supports.
When the CRE completes initialization, it returns control to the C run-time library. The
run-time library completes its own initialization and returns control to your main
function, which begins executing the instructions in the program’s object code.
For Guardian processes, the C run-time library performs several additional initialization
tasks during the process startup phase, including:
•
Processing the startup message sent by the command interpreter
•
Processing any command interpreter PARAM or ASSIGN messages
•
Opening the standard input, output, and error files: stdin, stdout, and stderr
•
Invocation of the constructors for global and static variables in C++
As it performs these tasks, the C run-time library acquires detailed information
regarding the environment in which the process is executing. The library saves this
information in the argument array. The argument array contains program and argument
information extracted from the RUN command—namely, program-file and each of
the arguments in args-list.
For Guardian processes, the library also saves information in the environment array.
The environment array contains environment parameters from PARAM messages.
The Guardian C run-time library includes six functions that allow the retrieval of the
process startup message, the PARAM message, and the ASSIGN messages. For
details, see Retrieving Startup Information on page 19-6.
The Standard Input, Output, and Error Files
In the Guardian environment, the CRE automatically opens three standard files: stdin,
stdout, and stderr. You can suppress the automatic opening of these files with the
NOSTDFILES pragma.
In the OSS environment, the standard files are controlled by the OSS file system, not
the CRE. For information on using the standard files in the OSS environment, refer to
the Open System Services Programmer’s Guide.
The three standard files for ANSI-model I/O are associated to physical files as follows:
•
stdin denotes the physical file specified by the IN option of the RUN command. If
you do not use the IN option, stdin denotes the command interpreter’s default input
file, which is usually your home terminal.
•
stdout denotes the physical file specified by the OUT option of the RUN command.
If you do not use the OUT option, stdout denotes the command interpreter’s default
output file, which is usually your home terminal.