title: freopen: reverting back to original stream
body: <p>I needed to forward stdout to different files to separate some prints produced and the reverting back to normal stdout.</p>
  
  <p>I used <code>freopen</code> to switch to the file in this way:</p>
  
  <pre><code>char name[80];
  memset(name, 0, 80);
  strcpy(name, "./scripts/asm/");
  strcat(name, m_func-&gt;m_name-&gt;m_value);
  strcat(name, ".shasm");
  freopen(name, "w", stdout);
  </code></pre>
  
  <p>And it actually works, but at the end of the process (mind that stdout is redirected many times in the previous same way) I'm not able to revert it to original stdout. I tried the following: </p>
  
  <pre><code>freopen("/dev/stdout", "w", stdout);
  </code></pre>
  
  <p>but it doesn't seem to work.. just for information I'm developing on macosx.</p>
  
  <p>What should I do?</p>
  
  <p>Thanks in advance</p>