title: Writing vector<double> to binary file and reading it again
body: <p>I'm trying to write a vector of doubles to a binary file.
  After doing this I want to read it. This doesn't seem to work.
  Here is the code:</p>
  
  <pre><code>ofstream bestand;
  vector&lt;double&gt; v (32);
  const char* pointer = reinterpret_cast&lt;const char*&gt;(&amp;v[0]);
  size_t bytes = v.size() * sizeof(v[0]);
  bestand.open("test",ios::out | ios::binary);
  for(int i = 0; i &lt; 32; i++)
  {
     v[i] = i;
     cout &lt;&lt; i;
     }
  bestand.write(pointer, v.size());
  bestand.close();
  ifstream inlezen;
  vector&lt;double&gt; v2 (32);
  inlezen.open("test", ios::in | ios::binary);
  char byte[8];
  bytes = v2.size() * sizeof(v2[0]);
  inlezen.read(reinterpret_cast&lt;char*&gt;(&amp;v2[0]), bytes);
  for(int i =0; i &lt; 32; i++){
  
   cout &lt;&lt; endl &lt;&lt; v2[i] &lt;&lt; endl;
   }
  </code></pre>
  
  <p>This outputs "0 1 2 3 0 0 0......" so it seems it reads the first 4 numbers correctly.</p>