title: How can i correctly create a vector of arrays?
body: <p>I'm new to c++ and i'm trying to create a std::vector of arrays, but whenever i push_back a new element it seems that all of the previous elements get overwritten with the new value i just added.
  (I need to use the c++ default arrays rather than std::array or other containers because i need to pass them to a function that only accepts those).</p>
  <p>The following code and output show an example of what is happening:</p>
  <pre><code>std::vector&lt;int*&gt; tuples;
  for( int i = 0; i &lt; 10; i++ )
  {
      for( int j = 0; j &lt; 5; j++ )      
      {
          int tuple[] = { i, j };
          tuples.push_back( tuple );      
      }
  }
  
  for( int i = 0; i &lt; tuples.size(); i++ )        
      std::cout &lt;&lt; i &lt;&lt; &quot;   &quot; &lt;&lt; tuples[i][0] &lt;&lt; &quot; &quot; &lt;&lt; tuples[i][1] &lt;&lt; std::endl;
  </code></pre>
  <p><a href="https://i.stack.imgur.com/o2622.png" rel="nofollow noreferrer">At the end every array in the vector has elements {9, 4}, which are the last values reached by i and j respectively</a></p>