Standard Input and Output: learn C/C ++. This professional term has been used since the first class. In my understanding, the input and output in the DOS window are as follows:ProgramInput and output. It is called standard input output ~
In comparison, the redirection program is used to specify the input and output devices. Routine: Redirect. cpp
# Include <iostream> using namespace STD; int main () {cout <input 2 numbers and press ENTER or more <Endl; For (int A, B; cin> A> B; cout <a + B <Endl); Return 0 ;}
Take this simple program as an example: Compile the Connection Program and generate an executable file
Run it in VC under Win.
In Linux, you can use the G ++/GCC compiler.
Take Linux as an example:
G ++ rediret. cpp-O redirect
Generate a redirect executable file. Run
./Redirect
On the command line interface, enter numbers, separate spaces, and enter the Enter key. The result is displayed on the command line interface.
This is the standard input output !!!
Let's take a look at the Redirection Program:
The source program is not changed, but the necessary parameters are added:
Run the following command;
First, create num.txt to store more than two numbers in it, preferably an even multiple.
Then
./Redirect <num.txt
In this way, the result is displayed on the command line interface, but you do not need to enter it on the terminal interface. That is to say, this redirection will change the input device to a TXT file instead of your terminal. You can also change the output device.
./Redirect <num.txt> res.txt
The result will not be displayed on terminal.
Note that each execution of the preceding command overwrites the original value. To avoid overwriting, add the file to the end of res.txt.
./Redirect <num.txt> res.txt
Yes ~~
Good luck ~~ Yaung