Back to DevOps Series
Standard Input, Standard Output, and Standard Error

Standard Input, Standard Output, and Standard Error

Every program running on an operating system is provided with three standard streams for communication:
Here Stream is : A stream is simply a path (or channel) through which data moves to or from a program.
 

Link Below :
Stream in more detailed explanation:
Stream in more detailed explanation:
 
  • stdin → The path through which a program receives input.
  • stdout → The path through which a program sends normal output.
  • stderr → The path through which a program sends error messages.
 
  1. Standard Input (stdin)
  1. Standard Output (stdout)
  1. Standard Error (stderr)

1. Standard Input (stdin)

Definition

Standard Input (stdin) is the default stream from which a program reads input.
By default, stdin is connected to the keyboard, but it can also be redirected to read from a file or another program.

Example (C++)

Loading...

Input

Loading...

Output

Loading...
Here, cin reads the value 25 from stdin.

2. Standard Output (stdout)

Definition

Standard Output (stdout) is the default stream used by a program to display its normal output.
By default, stdout is connected to the terminal (screen).

Example (C++)

Loading...

Output

Loading...
Here, cout writes the message to stdout.

3. Standard Error (stderr)

Definition

Standard Error (stderr) is the default stream used by a program to display error messages or diagnostic information.
Although stderr is also displayed on the terminal by default, it is separate from stdout. This separation allows errors to be handled independently from normal output.

Example (C++)

Loading...

Output

Loading...
Here, cerr writes the error message to stderr.

Combined Example

Loading...

Input

Loading...

Output

Loading...
In this example:
  • cin reads input from stdin.
  • cout displays normal messages through stdout.
  • cerr displays the error message through stderr.

Summary

Stream
Purpose
Default Device
C++ Object
stdin
Reads input
Keyboard
cin
stdout
Displays normal output
Terminal (Screen)
cout
stderr
Displays error messages
Terminal (Screen)
cerr
This is the standard definition and explanation you'll commonly find in operating systems and Linux documentation.