How can you restore a redirected standard stream?
C Interview Questions and Answers
(Continued from previous question...)
How can you restore a redirected standard stream?
The preceding example showed how you can redirect a standard stream from within your program. But what if later in your program you wanted to restore the standard stream to its original state? By using the standard C library functions named dup() and fdopen(), you can restore a standard stream such as stdout to its original state.
The dup() function duplicates a file handle. You can use the dup() function to save the file handle
corresponding to the stdout standard stream. The fdopen() function opens a stream that has been
duplicated with the dup() function.
(Continued on next question...)
Other Interview Questions
|