Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving stdin after using the redirection operator <

For a programming assignment, we have the following requirements:

  1. It needs to be a command-line program written in C.
  2. It needs to read text from a text document. However, we are to do this by using the Unix redirection operator < when running the program rather than having the program load the file itself. (So the program reads the text by pretending it's reading from stdin.)
  3. After reading the data from the file, the program is to poll the user for some extra information before doing its job.

After much research, I can't find a way to retrieve the "old" stdin in order to accomplish part (3). Does anybody know how or if this is even possible?

Technically part (3) is part of a bonus section, which the instructor probably didn't implement himself (it's very lengthy), so it's possible that this is not possible and it's an oversight on his part. However, I certainly don't want to jump to this conclusion.

like image 234
Zach Conn Avatar asked May 30 '26 21:05

Zach Conn


1 Answers

On linux, i would open the controlling terminal /dev/tty.

like image 181
sambowry Avatar answered Jun 02 '26 15:06

sambowry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!