Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I can add some information on the difference between the above answers.</p> <p>This - <code>[]</code> has higher precedence than this <code>*</code> when declaring an array. That combined with the assumption that arrays and pointers are always interchangeable (they are not) catches a lot of people out. </p> <p>Naively one would assume that <code>int *arr[]</code> would be a pointer to an array because read from left to right this is a natural assumption. </p> <p>However it is actually an array of integer pointers. You want a pointer to an array? Tell C so:</p> <pre><code>int (*arr)[array_size]; </code></pre> <p>by setting your own precedence.</p> <p>As Carl has explained only answers <code>c</code> and <code>d</code> are applicable because in the <code>d</code> case you already have a pointer to a pointer and in the <code>c</code> case the array of pointers will decay to a pointer to a pointer when passed as an argument to a function.</p> <p>If you want a function that will read <code>a</code> and <code>b</code>, the signature needs to change to the following:</p> <pre><code>int funct(int (*array_name)[array_size]); </code></pre> <p>Note that in the above here you will need to specify the size of the array that the pointer will point to. </p> <p>Some good answers on two dimensional arrays and pointers to pointers <a href="https://stackoverflow.com/questions/2565039/how-are-multi-dimensional-arrays-formatted-in-memory">here</a> and <a href="https://stackoverflow.com/questions/897366/how-do-pointer-to-pointers-work-in-c/897414#897414">here</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. This table or related slice is empty.
    1. This table or related slice is empty.
    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