Substitutes the filenamed by a file specification for the open file addressed by a file pointer. The latter file is closed. Format #include <stdio.h> FILE *freopen (const char *file_spec, const char *a_mode, FILE *file_ptr, . . . );
1 – Arguments
file_spec A pointer to a string that contains a valid OpenVMS or UNIX style file specification. After the function call, the given file pointer is associated with this file. a_mode The access mode indicator. See the fopen function for a description. file_ptr A file pointer. . . . Optional file attribute arguments. The file attribute arguments are the same as those used in the creat function.
2 – Description
The freopen function is typically used to associate one of the predefined names stdin, stdout, or stderr with a file.
3 – Return Values
file_ptr The file pointer, if freopen is successful. NULL Indicates an error.