title: Switching data from array to vector
body: <p>I'm trying to convert my array to a vector, yet I'm having trouble printing it.
  It says in int main() in my for loop that v is undefined. When I define
  vector v; inside int main() the program compiles and runs and yet prints nothing.  What am I doing wrong?  </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt; 
  using namespace std;
  
  vector&lt;int&gt; a2v(int x[], int n)
  {
      vector&lt;int&gt; v(n);
      for(int i = 0; i &lt; n; i++)
      {
          v.push_back(x[i]);
      } 
      return(v);
  }
  
  int main()
  {
      vector&lt;int&gt; a2v(int x[], int n);
  
      int array[] = {11,12,13,14,15,16,17,18};
  
      a2v(array, 8);
  
      for(int i = 0; i &lt; v.size(); i++)
      {
          cout &lt;&lt; v[i] &lt;&lt;" ";
      }
      cout &lt;&lt; endl;
  
      return(0);
  }
  </code></pre>