title: Reading and writing a std::vector into a file correctly
body: <p>That is the point. How to write and read binary files with std::vector inside them?</p>
  
  <p>I was thinking something like:</p>
  
  <pre><code>//============ WRITING A VECTOR INTO A FILE ================
  const int DIM = 6;
  int array[DIM] = {1,2,3,4,5,6};
  std::vector&lt;int&gt; myVector(array, array + DIM);
  ofstream FILE(Path, ios::out | ofstream::binary);
  FILE.write(reinterpret_cast&lt;const char *&gt;(&amp;myVector), sizeof(vector) * 6);
  //===========================================================
  </code></pre>
  
  <p>But I don't know how to read this vector. Because I thought that the following was correctly but it isn't:</p>
  
  <pre><code>ifstream FILE(Path, ios::in | ifstream::binary);
  FILE.read(reinterpret_cast&lt;const char *&gt;(&amp;myVector), sizeof(vector) * 6);
  </code></pre>
  
  <p>So, how to perform the operation?</p>