title: C++ - Write void function value to file
body: <p>I have void c++ function which output the numbers and whenever I call the function it shows all numbers but when i try to write those numbers to file it gives me an error</p>
  
  <p>I have already tried this</p>
  
  <pre><code>void average(int num)
  {
  num = 2;
  cout &lt;&lt; num;
  }
  
   int main() {
  
          int num;
          average(num);
  
          ofstream file("tests.txt");
          file&lt;&lt; average(num); // on file it should write 2
   }
  </code></pre>
  
  <p>It gives an error "error: no match for 'operator&lt;&lt;'"</p>
  
  <p>Does anyone know what am i doing wrong?</p>