How to use redirection in C for file input
Using redirection sends the contents of the input file to stdin, so you need to read from stdin inside your code, so something like (error checking omitted for clarity)
Using redirection sends the contents of the input file to stdin, so you need to read from stdin inside your code, so something like (error checking omitted for clarity)
The simple naive way that is slow because it opens and positions the file pointer to End-Of-File multiple times. A better way – easier to write, and faster because the file is opened and positioned only once. Another good and fast way that only opens and positions the file once Edit 2020-04-17 Every now and … Read more
You can script it with a tool like expect (there are handy bindings too, like Pexpect for Python).