Reopen a file : File Open « File « C / ANSI-C






Reopen a file

#include <stdio.h>

int main(void)
{
  char str[80];

  freopen("OUTPUT", "w", stdout);

  printf("Enter a string: ");
  gets(str);
  printf(str);

  return 0;
}


           
       








Related examples in the same category

1.Get file name from command line and open the file
2.Open a file and close it
3. Open a file: how to use fopen
4. Reopen a stream with a different file and mode: how to use freopen
5.Open a file for read