title: c print array length
body: <p>as part of a larger task I'm trying to print the length of an array in C, i.e how many elements are in an array. The array is an array of doubles, and I want to print a single integer which is how many doubles are in the array.
  I have this code:</p>
  
  <pre><code>int array_length( double array[] ) {
      double length = 0;
      length = sizeof(array) / sizeof(double);
      printf("%G", length);
      return 0;
  }
  </code></pre>
  
  <p>and I call it in main like this:</p>
  
  <pre><code>int main( void ) {
      double test[] = {1.1,2.2,3.3,4.4,5.5};
      array_length(test);
      return 0;
  }
  </code></pre>
  
  <p>however this returns the error:</p>
  
  <blockquote>
    <p>error: ‘sizeof’ on array function parameter ‘array’ will return size
    of ‘double *’ [-Werror=sizeof-array-argument]</p>
  </blockquote>
  
  <p>research has told me that </p>
  
  <pre><code>sizeof(array) / sizeof(double);
  </code></pre>
  
  <p>will give me the length of an array, and I am trying to using "%G" to allow me to print the double that this code returns.</p>
  
  <p>I believe that "double*" means long double, so I tried changing "%G" to "%LG" and all uses of "double" to "long double", but that did not solve the problem. What is going on here?</p>