title: In C how to get number of items in array of pointers to char strings
body: <p>I want to implement the following function to print the contents of several <code>char</code> strings which are referenced through a pointer array.  How can I determine how many pointers there are without passing the total as an argument of the function?</p>
  
  <p>If it was an array of type <code>int</code> then it would be possible to use the <code>sizeof()</code> function but given that each item of my array is a pointer to a <code>char</code> string and each string could be of different length I don't think I can use this approach.  </p>
  
  <pre><code>void printCharArray(char *arr[]){
  
      int length = sizeof(arr) / sizeof(char); /* this does not give correct 
                                            number of items in the pointer array */
  
      for (int i=1;i&lt;=length; i++) {
          printf("Array item: [%s]",arr[i]);
      }
  
  }
  </code></pre>