C Interview Questions and Answers

 

How can I get back to the interactive keyboard if stdin is redirected?

I'm trying to write a program like ``more.'' How can I get back to
the interactive keyboard if stdin is redirected?





There is no portable way of doing this. Under Unix, you can open the special file
/dev/tty. Under MS-DOS, you can try opening the ``file'' CON, or use routines
or BIOS calls such as getch which may go to the keyboard whether or not input is
redirected.

Posted by:Richards