title: Expected or unexpected Segmentation errors?
body: <p>I am working on code security. So the code discussed below is known to be vulnerable.</p>
  <p>I want to understand why running the code below has no segmentation error</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(){
      int a[3]={0,1,2};
      for (int i=0; i&lt;=400; i++)
        printf(&quot;value of a[%d] is %d\n&quot;,i, a[i]);      
  
  }
  </code></pre>
  <p>but running the code below, with the loop bound changed to 4000 from 400, has a segmentation error? I would like to know why there is the segmentation error in one case but not in the other.</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(){
      int a[3]={0,1,2};
      for (int i=0; i&lt;=4000; i++)
        printf(&quot;value of a[%d] is %d\n&quot;,i, a[i]);      
  
  }
  </code></pre>