I want to use file as my standard i/o how do I redirect standard I/O to read data from/to file.
You can use C library function freopen() for this purpose. You can implement this like for inputting and getting corresponding output file.
freopen(“input_filename.in”,“r”,stdin) //must be open in read mode and extension should be .in
freopen(“output_filename.out”,“w”,stdout) //created in write mode and auto-generated during runtime
You can use input redirection. If your input file is “input.txt” and your program is a.out, Run it like this:
./a < input.txt
Output redirection can also come in handy at times. Use it like this:
./a > output.txt