title: How does this piece of code determine array size without using sizeof( )?
body: <p>Going through some C interview questions, I've found a question stating "How to find the size of an array in C without using the sizeof operator?", with the following solution. It works, but I cannot understand why.</p>
  
  <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt;
  
  int main() {
      int a[] = {100, 200, 300, 400, 500};
      int size = 0;
  
      size = *(&amp;a + 1) - a;
      printf("%d\n", size);
  
      return 0;
  }
  </code></pre>
  
  <p>As expected, it returns 5.</p>
  
  <p>edit: people pointed out <a href="https://stackoverflow.com/questions/16019009/find-size-of-array-without-using-sizeof-in-c">this</a> answer, but the syntax does differ a bit, i.e. the indexing method</p>
  
  <pre class="lang-c prettyprint-override"><code>size = (&amp;arr)[1] - arr;
  </code></pre>
  
  <p>so I believe both questions are valid and have a slightly different approach to the problem. Thank you all for the immense help and thorough explanation!</p>