title: How to strip away vector container and return an array?
body: <p>When reading in files, it's convenient to allocate the memory via a vector:</p>
  
  <pre><code>someType* readCSV() {
      std::vector&lt;someType&gt; vec;
      someType x;
      ...
      while(fscanf(f, parser, &amp;x) != EOF) {
          vec.push_back(x);
          getc(f); // skip comma
      }
      return &amp;vec[0];
  }
  </code></pre>
  
  <p>But I just want to return an normal array (I'm working with CUDA afterwards whose API uses pointers).</p>
  
  <p>So the question is whether <code>vec</code> going out of scope at the end of the function call will destroy the data it contains, and if there is anything I can do preserve it.</p>