Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>freopen</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
freopen

Usage

   #include <stdio.h>
   FILE *freopen(const char *name,const char *mode,FILE *fp);

   ANSI

Description

   Closes file indicated by fp. Errors while closing the file are ignored.
   Open a new file and associate the stream fp with it. name and mode have
   the same meaning as in fopen.

Example 

   #include <stdio.h>
   #include <stdlib.h>

   FILE *fp;

   int main()
   {
       fp = freopen("file.dat", "w+", stdout);
       if(fp == NULL) {
           fprintf(stderr,"error on freopen\n");
           return EXIT_FAILURE;
       }
       else
           fprintf(fp,"This data will go to file.dat\n");
       return EXIT_SUCCESS;
   }

Return Value

   freopen returns fp if successful, otherwise a NULL.

See Also

   fclose, fopen, open




See Also: fclose fopen open

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson