title: ofstream doesn't write buffer to file
body: <p>I'm trying to write the contents of buf pointer to the file created by ofstream.</p>
  
  <p>For some reason the file is empty, however the contents of buf is never empty...  What am I doing wrong?</p>
  
  <pre><code>void DLog::Log(const char *fmt, ...)
  {
      va_list varptr;
  
      va_start(varptr, fmt);
  
      int n = ::_vscprintf(fmt, varptr);
      char *buf = new char[n + 1];
      ::vsprintf(buf, fmt, varptr);
  
      va_end(varptr);
  
      if (!m_filename.empty())
      {
  
          std::ofstream ofstr(m_filename.c_str(), ios::out);
  
          ofstr &lt;&lt; *buf; // contents of *buf are NEVER empty, however nothing is in file??
  
          ofstr.close();
      }
  
  
      delete [] buf;
  }
  </code></pre>