A C program can use SYSOUT as follows:
An open function (
fopen
/fopen64
,freopen
/freopen64
,open
/open64
) is used to open a file with the name "(SYSOUT)" or "(SYSTERM)" for writing. The file pointer returned by the open function then serves as an argument for a subsequent input function.Example
FILE *fp; fp = fopen("(SYSTERM)", "w"); fputc(fp);
For output functions, the file pointer
stdout
or the file descriptor 1 is specified as the file argument.Examples
fputc(stdout);
write(1, buf, n);
In this case, the file pointer
stderr
or the file descriptor 2 is specified as the file argument for output functions.Output functions that write to
stdout
/stderr
by default (e.g.printf
,puts
,putchar
orperror
) are used.
If a parameter line was requested with PARAMETER-PROMPTING=YES (in the RUNTIME-OPTIONS compiler option), this parameter line can be used to redirect the standard output (file pointer stdout
or file descriptor 1) and the standard error output (file pointer stderr
or file descriptor 2) to a cataloged file. Please refer to your C and C++ User Guides.
This reassignment has no effect on files that were opened with the name "(SYSOUT)" or "(SYSTERM)".