GLib.freopen
Description: Reference for GLib.freopen

### Function

# GLibfreopen

since: 2.6

#### Declaration

    FILE*
    g_freopen (
      const gchar* filename,
      const gchar* mode,
      FILE* stream
    )

#### Description

A wrapper for the POSIX `freopen()` function. The `freopen()` function opens a file and associates it with an existing stream.

See your C library manual for more details about freopen().

Available since: 2.6

#### Parameters

`filename`

  Type: `const gchar*`

  A pathname in the GLib file name encoding (UTF-8 on Windows)

  The data is owned by the caller of the function.
  The value is a file system path, using the OS encoding.

`mode`

  Type: `const gchar*`

  A string describing the mode in which the file should be opened.

  The data is owned by the caller of the function.
  The value is a NUL terminated UTF-8 string.

`stream`

  Type: `FILE*`

  An existing stream which will be reused, or `NULL`.

  The argument can be `NULL`.
  The data is owned by the caller of the function.

#### Return value

Type: `FILE*`

A FILE* if the file was successfully opened, or `NULL` if an error occurred.

The data is owned by the called function.
The return value can be `NULL`.