User Tools

Site Tools


c:stdio.h:freopen

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c:stdio.h:freopen [2024/02/16 01:05] (current)
Line 1: Line 1:
 +{{keywords>wiki library source code example reference}}
 +====== freopen ======
 +
 +<code c>
 +#include <stdio.h> /* including standard library */
 +//#include <windows.h> /* uncomment this for Windows */
 +
 +    FILE *freopen( const char *fname, const char *mode, FILE *stream );
 +</code>
 +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 =====
 +<code c>
 +/* 
 + * 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;
 +}
 +</code>
 +
 +==== freopen output example ====
 +    user@host:~$ ./freopen 
 +    user@host:~$ cat test.txt 
 +    This content is written to a file
 +    
  

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/stdio.h/freopen.txt · Last modified: 2024/02/16 01:05 (external edit)

Impressum Datenschutz