HP C/iX Reference Manual (31506-90011)

124 Chapter8
Compiling and Running HP C/iX Programs
Running HP C/iX Programs
Running HP C/iX Programs
You can run HP C/iX programs using the RUN command or by entering the program name
(an implied run). You can pass parameters to the main program and redirect the standard
input (stdin), standard output (stdout), and error output (stderr) to specific files by
using the INFO string.
Program Parameters
You can pass parameters to an HP C/iX program by declaring them in the function main as
shown in the following example:
main(argc, argv, envp, parm, info)
int argc;
char *argv[];
char *envp[];
int parm;
char *info;
NOTE
The envp parameter is required as a placeholder in the formal parameter list
for main. This parameter is not initialized on MPE/iX and must not be used. It
is provided for compatibility with programs on other systems that pass envp
to main.
You invoke the program (called MYPROG) with the following command:
RUN MYPROG; INFO="STR1 STR2 STR3"; PARM=11
The C compiler separates the INFO string into argv arguments using blanks as argument
delimiters and sets argc to the number of argv elements. To pass an argument that
contains embedded blanks, enclose the argument in quotes. Use single quotes to delimit
the argument if the INFO string is enclosed in double quotes; use double quotes if the
INFO string is enclosed in single quotes. A quote may be included within a quoted string
by escaping the quote with another quote similar to the manner in which the MPE/iX
command interpreter allows quotes to be passed in the INFO string. The argv[0]
argument is set equal to the program name, and argv[argc] is set equal to NULL. The
PARM and INFO values are passed unchanged to the program. The order of the
declaration of parameters to main is significant, but the names of the formal parameters
can be any valid identifier. For the previous RUN command:
argv[0] = MYPROG.MYGROUP.MYACCT
argv[1] = "STR1"
argv[2] = "STR2"
argv[3] = "STR3"
argv[4] = NULL
argc = 4
parm = 11
info = "STR1 STR2 STR3"
To include blanks within a single entry in the argv array, the following command: