Fast way to write data from a std::vector to a text file
<p>I currently write a set of doubles from a vector to a text file like this:</p>

<pre><code>std::ofstream fout;
fout.open("vector.txt");

for (l = 0; l &lt; vector.size(); l++)
    fout &lt;&lt; std::setprecision(10) &lt;&lt; vector.at(l) &lt;&lt; std::endl;

fout.close();
</code></pre>

<p>But this is taking a lot of time to finish. Is there a faster or more efficient way to do this? I would love to see and learn it. </p>