Uses freopen( ) to redirect stdout to a file called OUTPUT: - C File

C examples for File:File Operation

Description

Uses freopen( ) to redirect stdout to a file called OUTPUT:

Demo Code

#include <stdio.h>

int main(void)
{
   char str[80];/*w w  w. j a  va  2 s  .  co m*/

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

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

   return 0;
}

Result


Related Tutorials