title: C++ input to Arrays Switches Variables Around
body: <p>I'm attempting to create a 3x3 table in C++, but the last value of each row is being replaced with the first value of the row above.</p>
  <pre><code>#include&lt;iostream&gt;
  #include&lt;iomanip&gt;
  #include&lt;fstream&gt;
  using namespace std;
  
  
  
  void fillArray(int *arrayRow1, int *arrayRow2, int *arrayRow3)
  {
      cout &lt;&lt; &quot;Enter the number for row 1 column 1: &quot; &lt;&lt; endl;
      cin &gt;&gt; arrayRow1[0];
      cout &lt;&lt; &quot;Enter the number for row 1 column 2: &quot; &lt;&lt; endl;
      cin &gt;&gt; arrayRow1[1];
      cout &lt;&lt; &quot;Enter the number for row 1 column 3: &quot; &lt;&lt; endl;
      cin &gt;&gt; arrayRow1[2];
  
      cout &lt;&lt; &quot;Enter the number for row 2 column 1: &quot; &lt;&lt; endl;
      cin &gt;&gt; arrayRow2[0];
      cout &lt;&lt; &quot;Enter the number for row 2 column 2: &quot; &lt;&lt; endl;
      cin &gt;&gt; arrayRow2[1];
      cout &lt;&lt; &quot;Enter the number for row 2 column 3: &quot; &lt;&lt; endl;
      cin &gt;&gt; arrayRow2[2];
  
      cout &lt;&lt; &quot;Enter the number for row 3 column 1: &quot; &lt;&lt; endl;
      cin &gt;&gt; arrayRow3[0];
      cout &lt;&lt; &quot;Enter the number for row 3 column 2: &quot; &lt;&lt; endl;
      cin &gt;&gt; arrayRow3[1];
      cout &lt;&lt; &quot;Enter the number for row 3 column 3: &quot; &lt;&lt; endl;
      cin &gt;&gt; arrayRow3[2];
  
  
      cout &lt;&lt; &quot;Resulting Table:&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;_______&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;|&quot; &lt;&lt; arrayRow1[0] &lt;&lt; &quot;|&quot;  &lt;&lt; arrayRow1[1]  &lt;&lt; &quot;|&quot; &lt;&lt; arrayRow1[2] &lt;&lt; &quot;|&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;________&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;|&quot; &lt;&lt; arrayRow2[0] &lt;&lt; &quot;|&quot;  &lt;&lt; arrayRow2[1]  &lt;&lt; &quot;|&quot; &lt;&lt; arrayRow2[2] &lt;&lt; &quot;|&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;________&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;|&quot; &lt;&lt; arrayRow3[0] &lt;&lt; &quot;|&quot;  &lt;&lt; arrayRow3[1]  &lt;&lt; &quot;|&quot; &lt;&lt; arrayRow3[2] &lt;&lt; &quot;|&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;_______&quot; &lt;&lt; endl;
      
      
  }
  
  int main(){
  int arrayRow1[2], arrayRow2[2], arrayRow3[2];
  fillArray(arrayRow1, arrayRow2, arrayRow3);
  }
  
  
  </code></pre>
  <p>When 1, 2, 3, 4, 5, 6, 7, 8, 9 is entered it resulting the the following output:</p>
  <pre><code>________
  |1|2|4|
  ________
  |4|5|7|
  ________
  |7|8|9|
  ________
  </code></pre>
  <p>The expected output is:</p>
  <pre><code>________
  |1|2|3|
  ________
  |4|5|6|
  ________
  |7|8|9|
  ________
  
  </code></pre>
  <p>What is cause this issue?</p>