title: Common array length macro for C?
body: <p>I've seen several macros for array length floating around:</p>
  
  <p>From <a href="https://stackoverflow.com/questions/4307929/is-there-any-shortcut-for-array-size-length-in-c">this question</a>:</p>
  
  <ul>
  <li><code>#define length(array) (sizeof(array)/sizeof(*(array)))</code></li>
  <li><code>#define ARRAY_LENGTH(array) (sizeof((array))/sizeof((array)[0]))</code></li>
  <li><code>#define SIZE(array, type) (sizeof(array) / (sizeof(type))</code></li>
  </ul>
  
  <p>And Visual Studio's <a href="http://msdn.microsoft.com/en-us/library/ms175773(v=VS.100).aspx" rel="noreferrer"><code>_countof</code></a>:</p>
  
  <pre><code>#define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
  </code></pre>
  
  <p>What I'd like to know is:</p>
  
  <ol>
  <li>What's the difference between those using <code>array[0]</code> and <code>*array</code>?</li>
  <li>Why should either be preferred?</li>
  <li>Do they differ in C++?</li>
  </ol>