title: Does ofstream close its files automatically?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4802494/do-i-need-to-close-a-stdfstream">do I need to close a std::fstream?</a>  </p>
  </blockquote>
  
  
  
  <pre><code>int main() {
      ofstream a("a.txt");
      a &lt;&lt; "A" &lt;&lt; endl;
      //a.close();
  }
  </code></pre>
  
  <p>This works fine, but isn't it necessary to close the file at the end of the program?</p>