Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As always, <a href="http://cdecl.org" rel="noreferrer">http://cdecl.org</a> is your friend:</p> <ul> <li><a href="http://cdecl.ridiculousfish.com/?q=char+%2a+%28%2aarr%29%5B%5D" rel="noreferrer"><code>char * (*arr)[]</code></a> - "declare arr as pointer to array of pointer to char"</li> <li><a href="http://cdecl.ridiculousfish.com/?q=char+%2a%2a%2a+arr" rel="noreferrer"><code>char *** arr</code></a> - "declare arr as pointer to pointer to pointer to char"</li> </ul> <p>These are not the same. For a start, the first is an incomplete type (in order to use a pointer to an array, the compiler needs to know the array size).</p> <p>Your aim isn't entirely clear. I'm guessing that really all you want to do is modify the underlying data in your array of <code>char *</code>. If so, then you can just pass a pointer to the first element:</p> <pre><code>void my_func(char **pointers) { pointers[3] = NULL; // Modify an element in the array } char *array_of_pointers[10]; // The following two lines are equivalent my_func(&amp;array_of_pointers[0]); my_func(array_of_pointers); </code></pre> <p>If you <strong>really</strong> want to pass a pointer to an array, then something like this would work:</p> <pre><code>void my_func(char *(*ptr)[10]) { (*ptr)[3] = NULL; // Modify an element in the array } char *array_of_pointers[10]; // Note how this is different to either of the calls in the first example my_func(&amp;array_of_pointers); </code></pre> <p>For more info on the important difference between arrays and pointers, see the dedicated chapter of the C FAQ: <a href="http://c-faq.com/aryptr/index.html" rel="noreferrer">http://c-faq.com/aryptr/index.html</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload