title: Writing ALL program output to a txt file in C++
body: <p>I need to write all my program output to a text file. I believe it's done this way, </p>
  
  <pre><code>sOutFile &lt;&lt; stdout;
  </code></pre>
  
  <p>where sOutFile is the ofstream object that creates the file like this:</p>
  
  <pre><code>sOutFile("CreateAFile.txt" ); // CreateAFile.txt is created.
  </code></pre>
  
  <p>When I insert the stdout into the sOutFile object, I get some code which seems to resemble <del>octal</del> [hexadecimal] code or an address of some kind in the text file that I created.</p>
  
  <pre><code>0x77c5fca0
  </code></pre>
  
  <p>But what's confusing to me is that in my program I use cout several times. Mostly just literal statement. If I'm not mistaken that is the program output.</p>
  
  <p>If this code is an address, would it contain all of my output? Could I read it back in to the program and find out that way?</p>
  
  <p>What can I do to get ALL of my program output written to a text file?</p>