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.