title: Copy the contents of std::vector<char> into a char* buffer?
body: <p>I have an std::vector. I want to copy the contents of the vector into a char* buffer of a certain size.</p>
  
  <p>Is there a safe way to do this?</p>
  
  <p>Can I do this?</p>
  
  <pre><code>memcpy(buffer, _v.begin(), buffer_size);
  </code></pre>
  
  <p>or this?</p>
  
  <pre><code>std::copy(_v.begin(), _v.end(), buffer); // throws a warning (unsafe)
  </code></pre>
  
  <p>or this?</p>
  
  <pre><code>for (int i = 0; i &lt; _v.size(); i++)
  {
    *buffer = _v[i];
    buffer++;
  }
  </code></pre>
  
  <p>Thanks..</p>