How can I divide a vector in c++
<p>Ive tried with assign fxn but it doesnt work</p>

<pre><code>c.assign(v.begin(), v.begin() + (v.size() + 1) / 2)
d.assign(v.begin() + (v.size() + 1) / 2 + 1, v.end())
</code></pre>

<p>for eg vec = 1,2,3,4,5,6,7,8
then it produces result
vec1 = 1,2,3,4
vec2 = 6,7,8</p>