C++ - why does sizeof return the false value for an array when used as return value in a function : <p>I have a little problem regarding the size of an array (int, char, etc.). First of all I need to tell you, that I am a beginner in C++ with some background in some other programming languages. Now let us consider the following program: </p>

<pre><code>int IntArrayLength(int Array[]){

  return (sizeof(Array) / sizeof(Array[0]));
}

int main(){ 

   int array[] = {10,20,30,40,50};
   cout &lt;&lt; (sizeof(array) / sizeof(array[0])) &lt;&lt; endl; // returns 5, which is the correct value
   cout &lt;&lt; IntArrayLength(array) &lt;&lt; endl; // returns 2, no matter how many elements are in the array


}
</code></pre>

<p>Why does the function <code>IntArrayLength</code> return the value of 2 while the expression <code>(sizeof(array) / sizeof(array[0]))</code> returns the correct value, when not put into a function.</p>

<p>Thanks in advance!</p>
