title: How do I use fstream (specifically ofstream) through a functions parameters
body: <p>Hi I'm a <code>c++</code> beginner and this is one of my assignments and I'm a bit stuck. This isn't my entire code it's just a snippet of what I need help with. What I'm trying to do is have one function dedicated to exporting everything with that function into a <code>text</code> file which is called results.txt. So the line &quot;does this work&quot; should show up when I open the file, but when I run the file I get errors like</p>
  <blockquote>
  <p>&quot;Error C2065: 'out' : undeclared identifier&quot;</p>
  <p>&quot;Error C2275: 'std::ofstream' : illegal use of this type as an expression&quot;</p>
  <p>&quot;IntelliSense: type name is not allowed&quot;</p>
  <p>&quot;IntelliSense: identifier &quot;out&quot; is undefined&quot;</p>
  </blockquote>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  
  
  using namespace std;
  
  //prototypes
  void output(ofstream&amp; out);
  
  int main()
  {
  output(ofstream&amp; out);
      ifstream in;
      in.open(&quot;inven.txt&quot;);
      ofstream out;
      out.open(&quot;results.txt&quot;);
  return 0;
  }
  
  void output(ofstream&amp; out)
  {
  out &lt;&lt; &quot;does this work?&quot; &lt;&lt; endl;
  }
  </code></pre>
  <p>Right now it's really late and I'm just blanking out on what I'm doing wrong.</p>