title: C++ how to convert vector to an array?
body: <p>Can someone be able to tell me how to convert vector to an array?
  I have a function that returns a vector of double type with typical like this</p>
  
  <pre><code>std::vector&lt;double&gt;  x_vec = LinspaceArray_DK2(0, 5.0, 0.01);
  std::vector&lt;double&gt;  y_vec = Calculate_y_vec(x_vec);
  </code></pre>
  
  <p>However, following GSL (GNU scientific lib) function is expecting an array as an input</p>
  
  <pre><code>gsl_spline_init (spline, x_array, y_array, x_vec.length);
  </code></pre>
  
  <p>Here, x_array, y_array are arrays corresponding to vectors x_vec and y_vec.</p>
  
  <p>I tried following solution here (<a href="https://stackoverflow.com/questions/2923272/how-to-convert-vector-to-array-c">How to convert vector to array in C++</a>) which suggest conversion like this:</p>
  
  <pre><code>std::vector&lt;double&gt; v;
  double* a = &amp;v[0];
  </code></pre>
  
  <p>But, this type of conversion did not help with gsl_spline_init which expected arrays as inputs.</p>
  
  <p><strong>Updated:</strong></p>
  
  <p>I tried to call like this:</p>
  
  <pre><code>// Convert all vector to an array
  double* x_input_Array = &amp;x_input[0];
  double* y_input_Array = &amp;y_input[0];
  </code></pre>
  
  <p>and then call:</p>
  
  <pre><code>gsl_spline_init (spline, *x_input_Array, *y_input_Array, iNoOfPtsIni);
  </code></pre>
  
  <p>I am getting this error:
  error C2664: 'gsl_spline_init' : cannot convert parameter 2 from 'double' to 'const double []'  </p>
  
  <p>Thanks,
  DK</p>