title: How to redirect the output back to the screen after freopen("out.txt", "a", stdout)
body: <pre><code>#include &lt;stdio.h&gt;
  
  int main() {
      printf("This goes to screen\n");
      freopen("out.txt", "a", stdout);
      printf("This goes to out.txt");
      freopen("/dev/stdout", "a", stdout);
      printf("This should go to screen too, but doesn't\n");
  
      return 0;
  }
  </code></pre>
  
  <p>I call freopen to redirect the <em>stdout</em> to out.txt then I print something on the file, now I want to redirect it back to the screen, but <em>freopen("/dev/stdout", "a", stdout);</em> doesn't work. Is there any way to do that using ANSI C or POSIX system calls?</p>