Add Book to My BookshelfPurchase This Book Online

Chapter 4 - The Standard I/O Library

UNIX Systems Programming for SVR4
David A. Curry
 Copyright © 1996 O'Reilly & Associates, Inc.

Reassigning a File Pointer
Sometimes it is necessary to change the file that is associated with a specific file pointer. This is most often done with the pre-defined file pointers: stdin, stdout, and stderr. The function that does it is called freopen:
    #include <stdio.h>
    FILE *freopen(const char *filename, const char *type, FILE *stream);
The filename argument contains the path to the new file, and type indicates how the new file should be opened, as described earlier for fopen. The original file that stream referred to is closed. If freopen succeeds, it returns stream; if it fails, it returns the constant NULL.

Previous SectionNext Section
Books24x7.com, Inc © 2000 –  Feedback