title: Prevent array to writing to nonexistent index
body: <p>I have array of numbers like:</p>
  
  <pre><code>int a[10]={1,1,1,1,1,1,1,1,2,1};
  </code></pre>
  
  <p>I find position of 2 and then change the value of indexof(2)+4 and -4 to 2 too.</p>
  
  <p>Problem is that indexof(2)+4 does not exist which mean c will overwrite some memory that does not belong to array. How can I stop c to writing into indexes that exceed length of the array?</p>