Home » C++ Programming » Files and Streams » Question
  1. What is the output of this program in the file?
    #include <iostream>
    int main ()
    {
    freopen ("Sample.txt", "w", stdout);
    printf ("This is redirected to a file");
    fclose (stdout);
    return 0;
    }
    1. This is redirected
    2. Compilation Error
    3. This is redirected to a file
    4. Sample.txt
    5. None of these
Correct Option: C

In this program, We are sending the text to the file by opening the file using the function freopen.



Your comments will be displayed only after manual approval.