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

The three standard files for ANSI-model I/O are associated to physical files:
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.
stderr denotes the physical file specified in an ASSIGN STDERR command. If you do not use
the ASSIGN command, stderr denotes the command interpreter’s default output file, which is
usually your home terminal.
The IN and OUT options of the RUN command were described in Running Programs in the Guardian
Environment (page 319).
The ASSIGN command you use to specify the standard error file has the form:
ASSIGN STDERR, file-name
where file-name is a valid file name representing a physical file that the C compiler can access
as a text-type logical file. Note that you must enter this ASSIGN command before you run your
C program.
Invocation of Constructors for Global and Static Variables
During the startup of a C++ program, the constructors for global and static variables are invoked.
Global and static variables have storage class static, which means that they retain their values
throughout the execution of the entire program. All global variables have storage class static.
Local variables and class members can be given storage class static by explicit use of the
static storage class specifier.
Accessing Environment Information
You can access the environment information saved by the C library during program startup:
By calling the getenv() library function
By declaring parameters to the function main()
The getenv() function enables your program to access the environment array. The parameters
to main() enable your program to access both the environment and argument arrays. See the
Guardian TNS C Library Calls Reference Manual, Guardian Native C Library Calls Reference
Manual, or the Open System Services Library Calls Reference Manual. For more details on how
to use the getenv() function; the next subsection shows you how to declare parameters to main().
Parameters to the Function main
C enables you to declare up to three parameters to your program’s main function.
int main(int argc, char *argv[], char *env[]);
argc
is an integer value specifying the number of elements in the argument array argv.
argv
is the argument array. Each element (except for the last) points to a null-terminated string.
argv[0] points to the fully qualified name of the executing program. Each of the elements
argv[1] through argv[argc-1] points to one command-line argument; argv[argc] has the
pointer value NULL.
Program Initialization 321