Help us and donate little Bitcoins to pay the server costs: 1AXLPuRUBYc1JczTW4XS65GL6oWjNP2Vt2

User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer







because of the inhumane working conditions at amazon in Germany, I will offer the Amazon app no more! (ARD Reportage)
c:stdio.h:freopen

freopen

#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
 
    FILE *freopen( const char *fname, const char *mode, FILE *stream );

closes file associated with stream, then opens file filename with specified mode and associates it with stream. Returns stream or NULL on error.

C Sourcecode Example

/* 
 * freopen example code
 * http://code-reference.com/c/stdio.h/freopen 
 */
 
 
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
 
 
int main ( void )
{
  freopen ("test.txt","w",stdout);
  printf ("This content is written to a file");
  fclose (stdout);
  return 0;
}

freopen output example

  user@host:~$ ./freopen 
  user@host:~$ cat test.txt 
  This content is written to a file
  
advertising
c/stdio.h/freopen.txt · Last modified: 2013/01/22 22:02 (external edit)

The new Question & Answer System is online and waiting for your Questions about Programming problems http://ask.code-reference.com Impressum