How can I convert a char vector to a char array?
<p>I'm reading the bytes of a file (an image) to then convert into base64.</p>

<p>The bytes get written into a char vector called buffer, since I haven't found working examples for writing the bytes from the file into a char array</p>

<p>I do the char vector like such:</p>

<pre><code>ifstream infile("image.png", ios_base::binary);

infile.seekg(0, ios_base::end);
size_t length = infile.tellg();
infile.seekg(0, ios_base::beg);

vector&lt;char&gt; buffer;
buffer.reserve(length);
copy(istreambuf_iterator&lt;char&gt;(infile),
    istreambuf_iterator&lt;char&gt;(),
    back_inserter(buffer)); infile.read(&amp;buffer[0], length);
</code></pre>

<p>The base64 encoding function is:</p>

<pre><code>int base64_encode(unsigned char *source, size_t sourcelen, char *target, size_t targetlen);
</code></pre>

<p>I need to send the base64 encoded text to a website, so that it can be displayed on a page for example.</p>