title: Faster way to create tab deliminated text files?
body: <p>Many of my programs output huge volumes of data for me to review on Excel. The best way to view all these files is to use a tab deliminated text format. Currently i use this chunk of code to get it done:</p>
  
  <pre><code>ofstream output (fileName.c_str());
  for (int j = 0; j &lt; dim; j++)
  {
      for (int i = 0; i &lt; dim; i++)
          output &lt;&lt; arrayPointer[j * dim + i] &lt;&lt; " ";
      output &lt;&lt; endl;
  }
  </code></pre>
  
  <p>This seems to be a very slow operation, is a more efficient way of outputting text files like this to the hard drive?</p>
  
  <p>Update: </p>
  
  <p>Taking the two suggestions into mind, the new code is this:</p>
  
  <pre><code>ofstream output (fileName.c_str());
  for (int j = 0; j &lt; dim; j++)
  {
      for (int i = 0; i &lt; dim; i++)
          output &lt;&lt; arrayPointer[j * dim + i] &lt;&lt; "\t";
      output &lt;&lt; "\n";
  }
  output.close();
  </code></pre>
  
  <p>writes to HD at 500KB/s</p>
  
  <p>But this writes to HD at 50MB/s</p>
  
  <pre><code>{
      output.open(fileName.c_str(), std::ios::binary | std::ios::out);
      output.write(reinterpret_cast&lt;char*&gt;(arrayPointer), std::streamsize(dim * dim * sizeof(double)));
      output.close();
  }
  </code></pre>