Back to index

glibc  2.9
Functions
test-freopen.c File Reference
#include <mcheck.h>
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 27 of file test-freopen.c.

{
  FILE *fp;

  mtrace ();

  if (argc < 2)
    exit (1);

  fp = fopen (argv[1], "w");
  if (fp == NULL)
    {
      puts ("fopen failed: %m");
      exit (1);
    }

  fputs ("Hello world (mb)\n", fp);

  fp = freopen (argv[1], "a+", fp);
  if (fp == NULL)
    {
      puts ("freopen failed: %m");
      exit (1);
    }

  fputws (L"Hello world (wc)\n", fp);

  fclose (fp);

  return 0;
}

Here is the call graph for this function: