Go to the first, previous, next, last section, table of contents.


freopen

Syntax

#include <stdio.h>

FILE *freopen(const char *filename, const char *mode, FILE *file);

Description

This function closes file if it was open, then opens a new file like fopen(filename, mode) but it reuses file.

This is useful to, for example, associate stdout with a new file.

Return Value

The new file, or NULL on error.

Portability

ANSI, POSIX

Example

freopen("/tmp/stdout.dat", "wb", stdout);


Go to the first, previous, next, last section, table of contents.