title: Noobish Array problems: Run-Time Check Failure #2 - Stack around the variable 'arr' was corrupted
body: <p>I'll be pretty honest/upfront here- I'm both a noob to C++, to computer programming in general, and additionally, to this site as well. I'll just preface my question by saying that I did in fact look at other questions possibly related to my own, but it just felt like they were outside of my scope. With that said, here's my problem:</p>
  
  <p>I get this error message: </p>
  
  <p>"Run-Time Check Failure #2 - Stack around the variable 'arr' was corrupted."</p>
  
  <p>Here's my code. It's just a basic little thing for some array practice. The function multiTable outputs a multiplication table:</p>
  
  <hr>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  
  using namespace std;
  
  void multiTable();
  
  int main()
  {
      multiTable();
      return 0;
  }
  
  //Prints a 9 by 9 multiplication table;
  void multiTable()
  {    
      const int row = 9, col = 9;
      int arr[row][col];
  
      for(int i = 1; i &lt;= row; i++)
      {
          for(int j = 1; j &lt;= col; j++)
          {   
              arr[i][j] = j * i;
              cout &lt;&lt; setw(3);            
              cout &lt;&lt; arr[i][j];
          }
          cout &lt;&lt; endl;
      }
  }
  </code></pre>
  
  <hr>
  
  <p>I also want to mention that instead of the function call, had I just included all of the code contained within the function body in main, I don't get the run-time error. Why is it that when it's contained within a function, I get the runtime error, but when it's just in main, I don't get the error? And of course, what would I have to change in order for the function call to not produce the error?</p>