title: Best way to split a vector into two smaller arrays?
body: <p><strong>What I'm trying to do:</strong></p>
  
  <p>I am trying to split a vector into two separate arrays.  The current int vector contains an element per line in a text file.  The text file is a list of random integers.  </p>
  
  <p><strong>How I'm planning to do it:</strong></p>
  
  <p>My current idea is to create two regular int arrays, then iterate over the entire vector and copy <em>n/2</em> elements to each of the arrays.</p>
  
  <p><strong>What I would like to know:</strong></p>
  
  <p>What is the most elegant way of accomplishing my task?  I have a feeling that I can do this without iterating over the vector multiple times.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;fstream&gt;
  #include &lt;iterator&gt;
  #include &lt;iostream&gt;
  using namespace std;
  
  vector&lt;int&gt; ifstream_lines(ifstream&amp; fs)
  {
    vector&lt;int&gt; out;
    int temp;
    while(fs &gt;&gt; temp)
    {
      out.push_back(temp);
    }
    return out;
  }
  
  vector&lt;int&gt; MergeSort(vector&lt;int&gt;&amp; lines)
  {
    int split = lines.size() / 2;
    int arrayA[split];
    int arrayB[split];
  }
  
  int main(void) 
  {
    ifstream fs("textfile.txt");
    vector&lt;int&gt; lines;
    lines = ifstream_lines(fs);
  
    return 0;
  }
  </code></pre>
  
  <p>Thank you :)</p>