Solved How can I input/output redirect a file in C?

September 23, 2011 at 16:41:10
Specs: N/A
I have wrote a parse.c file that will recognize when the user type in '<' and '>' for input redirect and output redirect respectively. But, how do I actually carry out the function? Is there a built in function that I can use? or it needs to be written?
I would like to avoid the system() function.

Thanks much!

See More: How can I input/output redirect a file in C?

Report •

September 24, 2011 at 12:49:18
✔ Best Answer
All you need to redirect input and output is to use the file handles STDIN and STDOUT. You don't need to do anything else in the program to handle redirection. If, for example, You write output to STDOUT it will print to the console if no redirection is specified on the command line but will print to the file if you specify redirection.

So just write your parse.c program to take all input from STDIN and write all output to STDOUT and that's it.

Report •
Related Solutions

Ask Question