techpreparation-homepage

Home  Interview Questions  Aptitude Questions  Tutorials  Placement Papers  Search  Resume Guide  Soft Skills  Video  Forum  Blog


Technical Interview Questions

.Net Interview Questions
C++ Interview Questions
Unix Interview Questions
                              .........More

Download e-Books
C Interview Questions e-book

Aptitude Interview Questions
C/C++ Aptitude Questions
C Aptitude Questions
                              .........More

Online Quiz
C Online Quiz
C++ Online Quiz
                              .........More

 

 

  

  Home > C Interview Questions >

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.

 

Have a Question ? post your questions here. It will be answered as soon as possible.