title: sizeof Function not Working in Function
body: <p>When I run this code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  void PrintLengthOfArray(double arr[])
  {
    int total_bytes = sizeof(arr);
    int data_type_bytes = sizeof(arr[0]);
    int length = total_bytes / data_type_bytes;
  
    cout &lt;&lt; "method 2: \n";
    cout &lt;&lt; "total_bytes = " &lt;&lt; total_bytes &lt;&lt; "\n";
    cout &lt;&lt; "data_type_bytes = " &lt;&lt; data_type_bytes &lt;&lt; "\n";
    cout &lt;&lt; "length = " &lt;&lt; length &lt;&lt; "\n";
  }
  
  int main()
  {
    double arr[3] = {1,2,3};
    int total_bytes = sizeof(arr);
    int data_type_bytes = sizeof(arr[0]);
    int length = total_bytes / data_type_bytes;
  
    // first method
    cout &lt;&lt; "method 1: \n";
    cout &lt;&lt; "total_bytes = " &lt;&lt; total_bytes &lt;&lt; "\n";
    cout &lt;&lt; "data_type_bytes = " &lt;&lt; data_type_bytes &lt;&lt; "\n";
    cout &lt;&lt; "length = " &lt;&lt; length &lt;&lt; "\n\n";
  
    // second method
    PrintLengthOfArray(arr);
  }
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>method 1: 
  total_bytes = 24
  data_type_bytes = 8
  length = 3
  
  method 2: 
  total_bytes = 8
  data_type_bytes = 8
  length = 1
  </code></pre>
  
  <p>That is, it's like the <code>total_bytes = sizeof(arr)</code> statement in the function is only computing the size of an individual element, or just <code>arr[0]</code>.  What's going on?</p>