I'm trying to do I/O redirection in the open shell on repl.it. Taking the input from one file to run through the program. Outputting to a new file but nothing shows up? I'm only used to doing it from Windows using the CMD.
Shell:
~/maybe-lab6and7$ clang-7 -pthread -lm -o main main.c < address.txt >
open.txt
~/maybe-lab6and7$
After compiling and linking your program, if no compile problems and no link problems occur, you will have an executable in the current directory. (Lets say the executable is named: main
.)
Then, after changing the program permissions so main
is executable,
you can execute the program similar to:
./main < sourcedata.txt > destinationdata.txt
The result is that main
can read the sourcedata.txt
file from stdin
and the output from the program (instead of being displayed on the terminal) will be written to destinationdata.txt
.