Redirect standard pipes using freopen()

Home Forums C-programming.. Redirect standard pipes using freopen()

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #2342 Reply
    Humble
    Keymaster

    Most of the times, its a requirement that the standard pipes (stdin, stdout, stedrr) to be redirected to a different file stream by the program.. freopen() does the job.

    The freopen() function opens the file whose name is the string pointed to by path and associates the stream pointed to by stream with it.
    The original stream (if it exists) is closed. The mode argument is used just as in the fopen() function. The primary use of the freopen()
    function is to change the file associated with a standard text stream (stderr, stdin, or stdout).

    for ex:

    freopen(myfile, "w", stdout);
Viewing 1 post (of 1 total)
Reply To: Redirect standard pipes using freopen()
Your information: