The standard streams are preconnected input or output channels between a computer program and its environment (typically a text terminal) when it begins execution. These standard connections are provided in Unix and Unix-like operating systems, C and C++ runtime environments, and their successors. The three i/o connections are called standard input, standard output and standard error.
Unix provided several groundbreaking advances, one of which was to provide abstract devices: it removed the need for a program to know or care what kind of device it was communicating with. Older operating systems forced upon the programmer a record structure and, frequently non-orthogonal data semantics and device control. Unix eliminated this complexity with the concept of a data stream: an ordered sequence of data bytes which can be read until the end of file. A program may also write bytes as desired and need not (and can't easily) declare how many there will be, or how they will be grouped.
Another Unix breakthrough was to automatically associate input and output by default—the program (and programmer) did absolutely nothing to establish input and output for a typical input-process-output program (unless the program chose a different paradigm). In contrast, previous operating systems usually required some—often complex—job control language to establish connections, or the equivalent burden had to be orchestrated by the program.
Since Unix provided standard streams, the Unix C runtime environment was obligated to support it as well. As a result, most C runtime environments (and C's descendants), regardless of the operating system, provide equivalent functionality.
Unless redirected, input is expected from the text terminal which started the program.
The file descriptor for standard input is 0 (zero); the corresponding stdio.h variable is FILE *stdin
Unless redirected, standard output is the text terminal which initiated the program.
The file descriptor for standard output is 1 (one); the corresponding stdio.h variable is FILE *stdout
It is acceptable—and normal—for standard output and standard error to be directed to the same destination, such as the text terminal. Messages appear in the same order as the program writes them.
The file descriptor for standard error is 2; the corresponding stdio.h variable is FILE *stderr
Standard-Datenströme | Entrada estándar | Flux standard | Entrada estándar | Stderr | Fluxos padrão
This article is licensed under the GNU Free Documentation License.
It uses material from the
"Standard streams".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world