• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Standard Data Streams – stdin & stdout

By Abhishek Ghosh May 6, 2024 10:58 am Updated on May 6, 2024

Standard Data Streams – stdin & stdout

Advertisement

The standard streams are three data streams for input and output in the Unix operating system or related operating systems. They are also supported by the C standard library. Many programs automatically use the default input or output if no input or output files are specified on the command line.

Data streams are a continuous flow of data sets, the end of which is usually not foreseeable in advance; the records are processed continuously as soon as a new record has arrived. The individual data sets are of arbitrary but fixed type. The amount of records per time span (data rate) can vary and may become so large that the limited resources for further processing are not sufficient and the recipient has to react accordingly (e.g. discard records).

 

Standard input (stdin)

 

The standard input can be used to import data into a program. Usually, it is connected to the keyboard, which means that programs receive the user’s input through the standard input. On Unix, the default input is the device file /dev/stdin, the file descriptor is number 0.

Advertisement

---

For example, the default input for the less program is read from file test.txt.

Vim
1
$ less < test.txt

 

Standard output (stdout)

 

The standard output allows a program to output data. Usually, it is connected to the monitor, which means that programs send output texts to the user via the standard output. On Unix, the default output is the device file /dev/stdout, and the file descriptor is number 1. For example, the standard output of the find program is redirected to file example.txt.

Vim
1
$ find . -name '*.html' > example.txt

synonymous:

Vim
1
$ find . -name '*.html' 1 > example.txt

 

Standard error output (stderr)

 

The default error output is a second output stream that is designed to output error and status messages. Usually, it is also connected to the monitor; however, it can be redirected separately from the standard output so that error messages are not mixed with the output payload. On Unix, the default error output is the device file /dev/stderr, and the file descriptor is number 2.

For example, the error messages of the program find are redirected to the file newtest.txt, while the standard output is piped to the program less.

Vim
1
$ find . -name '*.html' 2 > newtest.txt | less

Standard Data Streams - stdin and stdout

 

Output redirection

 

Example 1: Redirect the error messages in stdout:

Vim
1
$ find . -name '*.html' 2>&1   | less

Here it is to be understood as follows: “Redirect stderr (also) to where stdout is pointing right now.”

Example 2:

Vim
1
$ find . -name '*.html' 2>&1 1> test.txt | less

stderr is redirected to the screen/Scrn:, then stdout to file test.txt; stderr is not redirected to the file, because it was not redirected “into stdout”, but “to where stdout points to”. The concatenation with less causes the error messages to be displayed page by page.

Example 3:

Vim
1
$ find . -name '*.html' 1> more_example.txt 2>&1 | less

stdout is redirected to file more_example.txt, then stderr to where stdout is currently pointing (i.e. also to the file), there is nothing left for less!

 

Programming languages C and C++

 

In the C programming language, the stdio.h header file defines three file pointers of type FILE *, named stdin, stdout, and stderr. These virtual files are usually opened automatically from the start of the program and can be used with most commands that access files.

In C++, the IOStream Library is used, which is part of the standard library. It is integrated with the header file iostream (without file extension), the access to the standard data streams is finally via the stream objects std::cout, std::cin and std::cerr.

Since this behavior is standardized by C++ or C, these standard data streams can also be found in non-Unix operating systems (such as Windows) or are simulated accordingly.

 

Java programming language

 

In the Java programming language, three streams are created in the java.lang.System class. System.in as InputStream, System.out as PrintStream, and System.err as PrintStream. These streams are automatically opened from the start of the program and can be used to access the standard data streams. Since this behavior is standardized by Java, these standard data streams can also be found in non-Unix operating systems or are simulated accordingly.

 

Python programming language

 

The standard data streams can also be accessed under Python via the file objects stdin, stdout and stderr provided in the sys module. The provided write method can be used to write to stdout and stderr.

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Standard Data Streams – stdin & stdout

  • What is /dev/null?

    What is /dev/null You Often View in the Commands and Shebang Scripts We Supply You? What is More Confusing Looking is /dev/null 2>&1? Get the Full Idea.

  • Humans.txt : Something Unlike Robots.txt

    Humans.txt unlike Robots.txt is a text file kept at root of the server to give credit the people behind a website and has only humane value.

  • Examples of Pipe or Pipelines Command

    In UNIX, Unix like operating systems including Linux, the shell of the OS have a mechanism called pipe or pipeline which looks like this |.

  • What Content ads.txt & app-ads.txt Should Have?

    Any serious blogger already know the basics on ads.txtbasics on ads.txtbasics on ads.txt. Gradually IAB and the browsers are implementing strict norms. Restriction on ads.txt can severely affect earning by blocking the network. Here is what content on ads.txt will return more money. ads.txt avoids spoofing. Ad fraud severely affects the earning of the industry. […]

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

vpsdime

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Cloud-Powered Play: How Streaming Tech is Reshaping Online GamesSeptember 3, 2025
  • How to Use Transcribed Texts for MarketingAugust 14, 2025
  • nRF7002 DK vs ESP32 – A Technical Comparison for Wireless IoT DesignJune 18, 2025
  • Principles of Non-Invasive Blood Glucose Measurement By Near Infrared (NIR)June 11, 2025
  • Continuous Non-Invasive Blood Glucose Measurements: Present Situation (May 2025)May 23, 2025
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2026 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy