Why do sizeof statsements produce different results?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/720077/calculating-size-of-an-array">Calculating size of an array</a><br>
  <a href="http://stackoverflow.com/questions/1975128/sizeof-an-array-in-the-c-programming-language">Sizeof an array in the C programming language?</a>  </p>
</blockquote>



<p>Why does <code>sizeof(arr)/(double)sizeof(arr[0])</code> work and <code>sizeof(arr+0)/(double)sizeof(arr[0])</code> not work?</p>

<p>And why does <code>sizeof(arr)/(double)sizeof(arr[0])</code> also not work when arr is passed to a function? Here is the full code example:</p>

<pre><code>#include &lt;iostream&gt;

using namespace std;

int givesize(int arr[])
{
   cout&lt;&lt;sizeof(arr)/(double)sizeof(arr[0])&lt;&lt;"\n";
}

int main()
{
   int arr[] = {1,2,3,4,5};
   cout&lt;&lt;sizeof(arr)/(double)sizeof(arr[0])&lt;&lt;"\n";
   cout&lt;&lt;sizeof(arr+2)/(double)sizeof(arr[0])&lt;&lt;"\n";
   givesize(arr);
   return 0;
}
</code></pre>

<p>Output
5
1
1</p>
