title: How to cast vector<unsigned char> to char*
body: <p>I have a buffer like this:</p>
  
  <pre><code>vector&lt;unsigned char&gt; buf
  </code></pre>
  
  <p>How can I cast it to char*?</p>
  
  <p>If I do:</p>
  
  <pre><code>(char *)buf
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>/home/richard/Desktop/richard/client/src/main.cc:102: error: invalid cast from type ‘std::vector&lt;unsigned char, std::allocator&lt;unsigned char&gt; &gt;’ to type ‘char*’
  </code></pre>
  
  <p>For those wondering why I am trying to do this. I need to pass the buffer to this function:</p>
  
  <pre><code>n_sent = sendto(sk,(char *)buf,(int)size,0,(struct sockaddr*) &amp;server,sizeof(server));
  </code></pre>
  
  <p>And it only accepts char*.</p>