### Standard Streams

The standard streams are primary sources for data input to programs and destinations for program output and diagnostic messages. Typically, programs designed to run from the command line use standard streams. Standard input comes from the keyboard unless redirected, and standard output goes to the display unless redirected.

IBM C and C++ Compilers supports the C standard streams and C++ iostreams.

C Standard Streams
Any program that includes the header <stdio.h> can use the C standard streams for I/O. The following streams are automatically set up by the run-time environment:

- stdin
  The input device from which your application normally retrieves its data. For example, the library function getchar uses stdin.
- stdout
  The output device to which your application normally directs its output. For example, the library function printf uses stdout.
- stderr
  The output device to which your application directs its diagnostic messages.

The streams stdprn and stdaux are reserved for use by the OS/2 operating system and are not supported by IBM C and C++ Compilers.

C++ iostreams
The iostream standard stream objects are:

- cin
  The standard narrow-character input stream.
- cout
  The standard narrow-character output stream.
- cerr
  The standard error stream. Output to this stream is unit-buffered. Characters sent to this stream are flushed after each insertion operation.
- clog
  Additional standard error stream. Output to this stream is fully buffered.

Stream Processing

Redirect Standard Streams
Direct I/O to Memory Files
Open Streams Using Data Definition Names
View Output to Standard Streams from PM Programs

I/O Buffering
File Handles for Standard Streams
Example of Storing Data in Text and Binary Streams
C Library Functions: Stream Input/Output
File Options Used with Data Definition Names