title: Copying from vector into a struct in C++ 11
body: <p>In C++ 11, what is the best way to perform the following code: </p>
  
  <pre><code>// definitions
  vector&lt;char&gt; rcvbuf; 
  
   struct somethingParams
  {
    char Magic[4]; 
    int Version; 
    int MsgID; 
    int MsgLen;
  };
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>struct somethingParams mParams; 
  memcpy(&amp;mParams, rcvbuf.data(), sizeof(somethingParams)); 
  rcvbuf.erase(rcvbuf.begin(), rcvbuf.begin + sizeof(somethingParams));
  </code></pre>
  
  <p>From what I've read, memcpy is not recommended in C++. I understand that it is "C-style". Is there a better way to achieve what I am doing above? (ie. Copying data from a vector into a struct.)</p>
  
  <p>Just see-ing if I can make it more "C++". </p>
  
  <p>Thanks. </p>