title: Length of array in function argument
body: <p>This is well known code to compute array length in C:</p>
  
  <pre><code>sizeof(array)/sizeof(type)
  </code></pre>
  
  <p>But I can't seem to find out the length of the array passed as an argument to a function:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int length(const char* array[]) {
    return sizeof(array)/sizeof(char*);
  }
  
  int main() {
    const char* friends[] = { "John", "Jack", "Jim" };
    printf("%d %d", sizeof(friends)/sizeof(char*), length(friends)); // 3 1
  }
  </code></pre>
  
  <p>I assume that array is copied by value to the function argument as constant pointer and reference to it should solve this, but this declaration is not valid:</p>
  
  <pre><code>int length(const char**&amp; array);
  </code></pre>
  
  <p>I find passing the array length as second argument to be redundant information, but why is the standard declaration of <code>main</code> like this:</p>
  
  <pre><code>int main(int argc, char** argv);
  </code></pre>
  
  <p>Please explain if it is possible to find out the array length in function argument, and if so, why is there the redundancy in <code>main</code>.</p>
  
  <hr>