Input Output Redirection

◀ Const Pointer▶ Math and Programming
Amazon Many modern operating systems, including MS-DOS and UNIX, support IO redirection. You can use this feature to pipe input from a file into a program or to store output from a program into a file.

For example, let’s say the executable name is prog which takes an int from the user. You can put the int in a file, say input.dat, then do the following:
prog < input.dat
Then prog will use the integer stored in input.dat to run. If later you want to store the output of prog into a file, say output.dat, you can do:
prog < input.dat > output.dat
When the program finishes executing, you can check the current directory and you will see the newly created output.dat. If the file was there initially, the new one may or may not overwrite it, depending on your script configuration and other factors.

If you get a warning that output.dat exists and you are not allowed to overwrite it, try >! instead of >.
Next let’s look at what an important role math plays in programming!
◀ Const Pointer▶ Math and Programming

fShare
Questions? Let me know!