title: copy() copying all but last element from vector to array c++
body: <p>I'm new to c++ and programming in general.  Feel free to leave any hints, tips, or suggestions about my code!!</p>
  
  <p>I am trying to copy my doubles from a vector to an array.  I used  <code>copy()</code> and it is copying all the elements except for the last.  So the last element in the array stays exactly the same as it was before I used copy.  So when I try to add the sums of the elements in the array, I don't get the correct sum.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>vector&lt;double&gt; myVector; 
  double myArray[4];
  double myDouble = 0.0;
  
      ...//(add elements to vector)
  
      copy(&amp;myVector[0], &amp;myVector[4], myArray);
  
  for(int i = 0; i &lt; 4; i++)
  {
      myDouble += myArray[i];
      if(i == 4)
          cout &lt;&lt; "The sum of your values is " &lt;&lt; fixed &lt;&lt; setprecision(2) &lt;&lt; myDouble &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Thank you!  Let me know if I need to be more specific.</p>