title: Convert std::vector to array
body: <p>I have a library which expects a array and fills it. I would like to use a std::vector instead of using an array. So instead of</p>
  
  <pre><code>int array[256];
  object-&gt;getArray(array);
  </code></pre>
  
  <p>I would like to do:</p>
  
  <pre><code>std::vector&lt;int&gt; array;
  object-&gt;getArray(array);
  </code></pre>
  
  <p>But I can't find a way to do it. Is there any chance to use std::vector for this?</p>
  
  <p>Thanks for reading!</p>
  
  <hr>
  
  <p>EDIT:
  I want to place an update to this problem:
  I was playing around with C++11 and found a better approach. The new solution is to use the function std::vector.data() to get the pointer to the first element.
  So we can do the following:</p>
  
  <pre><code>std::vector&lt;int&gt; theVec;
  object-&gt;getArray(theVec.data()); //theVec.data() will pass the pointer to the first element
  </code></pre>
  
  <p>If we want to use a vector with a fixed amount of elements we better use the new datatype std::array instead (btw, for this reason the variable name "array", which was used in the question above should not be used anymore!!).</p>
  
  <pre><code>std::array&lt;int, 10&gt; arr; //an array of 10 integer elements
  arr.assign(1); //set value '1' for every element
  object-&gt;getArray(arr.data());
  </code></pre>
  
  <p>Both code variants will work properly in Visual C++ 2010. Remember: this is C++11 Code so you will need a compiler which supports the features!</p>
  
  <p>The answer below is still valid if you do not use C++11!</p>