C/C++ Programmer's Guide (G06.25+)

Running and Debugging C and C++ Programs
HP C/C++ Programmer’s Guide for NonStop Systems429301-008
19-5
Parameters to the Function main
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.
env
is the environment array. Each element (except for the last) points to a null-
terminated string containing the name and value of one environment parameter.
The last element has the pointer value NULL.
When declaring parameters to the function main(), note the following:
The parameters to main() are optional; you can declare no parameters, just argc
and argv, or all three parameters. You cannot declare env alone.
The identifiers argc, argv, and env are simply the traditional names of three
parameters to main(); you can use identifiers of your own choosing.
The elements of the environment array env point to strings of the form:
"param-name=param-value"
where param-name is the name of the environment parameter and param-value
is its value.
The putenv() function sets the value of a parameter in the environment array,
and the getenv() function retrieves the value of a parameter in the environment
array.
Use env and putenv() with caution, however. The environment parameter of
main() is not updated when the environment array is enlarged or moved. Thus, using
the env parameter after invoking putenv() might result in inaccurate results. If you
need to modify and then examine the environment array, you should use the extermal
variable environ, which always has the correct value.