Interleaving the standard streams without sync_with_stdio()

Output can be interleaved without sync_with_stdio(), since the C++ standard streams are based on z/OS® XL C I/O. That is, cout can be interleaved with stdout, and clog can be interleaved with stderr. This is done by explicitly flushing cout or clog before calling the z/OS XL C output function. Results of attempting to interleave these streams without explicitly flushing, are undefined. Output to cerr doesn't have to be explicitly flushed, since cerr is unit-buffered.

Input to cin may be interleaved with input to stdin, without sync_with_stdio(), on a line-by-line basis. Results of attempting to interleave on a per-character basis are undefined. Figure 1 shows an example program and the output it produces.