title: Exceeding array bound in C -- Why does this NOT crash?
body: <p>I have this piece of code, and it runs perfectly fine, and I don't why:</p>
  
  <pre><code>int main(){
     int len = 10;
     char arr[len];
     arr[150] = 'x';
  }
  </code></pre>
  
  <p>Seriously, try it! It works (at least on my machine)!
  It doesn't, however, work if I try to change elements at indices that are too large, for instance index 20,000. So the compiler apparently isn't smart enough to just ignore that one line.</p>
  
  <p>So how is this possible? I'm really confused here...</p>
  
  <hr>
  
  <p>Okay, thanks for all the answers!</p>
  
  <p>So I can use this to write into memory consumed by other variables on the stack, like so:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  main(){
     char b[4] = "man";
     char a[10];
     a[10] = 'c';
     puts(b);
  }
  </code></pre>
  
  <p>Outputs "can". That's a really bad thing to do.</p>
  
  <p>Okay, thanks.</p>