title: Run-Time Check Failure #2 - Stack around the variable 'foo' was corrupted
body: <p>I'm studying for an exam and this is on my practice test. The question is "Which type of error does the following code fragment cause?"</p>
  
  <p>I was pretty sure there would be no errors, but I also can't get it to compile in VS13, I get the error:</p>
  
  <blockquote>
    <p>Run-Time Check Failure #2 - Stack around the variable 'foo' was corrupted.</p>
  </blockquote>
  
  <pre><code>    const int MAX = 500;
      int main(void)
      {
          int foo[MAX];
          for (int i = 0; i &lt;= MAX; i++)
          {
              foo[i] = i * 2;
              cout &lt;&lt; foo[i] &lt;&lt; endl;
          }
  
      cout &lt;&lt; "Press any key to exit." &lt;&lt; endl;
      cin.ignore(2);
  
      return 0;
      }
  </code></pre>