Redirection of input/output devices

Source: Internet
Author: User

If you have learned Java and used eclipse, you will find that the running of a program is not directly called to the console like a program compiled with vc6.0.

It is input and output below the eclipse software. That is, redirection. This blog post briefly introduces the redirection of input and output.

It is demonstrated through examples.

 

The redirection method is as follows:

Enter the program name [<enter device name] [> output device name] at the console command prompt.

Specifically, the program name is the program you have compiled and prepared to run; '<' is the name of the input device that you are directed to, such as I .txt; '> '.

The name of your output device, such as o.txt.

 

1. Create source program

#include<iostream>using namespace std;int main(){int i;while(cin>>i){cout<<i<<endl;}return 0;}

 

2. Place the following three files in the root directory of drive F:
 

Among them, test.exe.pdf is the executable file compiled by the code, and I .txt0000o.txt is the input and output device used for redirection. Of course,

You cannot store these three files elsewhere.

 

3. Redirect Only the input device

I .txt is the redirected input device. The data is prepared in advance. After you enter test <I .txtin the command prompt

Output to the console.

 

4. Only redirect the output device

O.txt is the redirected output device. Enter test> o.txt at the command prompt, and press Enter. Each time you enter a number and press enter, the number is displayed.

To o.txt.

 

5. Redirect input/output devices

I .txtis the input device for redirection, while o.txt is the output device for redirection. The content in I .txt is the first priority, while o.txt does not. When at the command prompt

Enter test <I .txt> o.txt and return to the vehicle. The content in I .txt is written into o.txt.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.