Note that there are some explanatory texts on larger screens.

plurals
  1. POpointers and multi-dimensional arrays
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/4810664/how-do-i-use-arrays-in-c">How do I use arrays in C++?</a><br> <a href="https://stackoverflow.com/questions/7586702/is-2d-array-a-double-pointer">Is 2d array a double pointer?</a><br> <a href="https://stackoverflow.com/questions/8669773/two-dimensional-arrays-and-pointers">Two dimensional arrays and pointers</a> </p> </blockquote> <p>I know that this is a very basic question but no amount of googling cleared this for me. That's why am posting it here. In c++ consider the declaration <code>int x[10];</code></p> <p>This is a 1-dimensional array with x being the base pointer that is it contains the address of the first element of the array. So <code>x</code> gives me that address and <code>*x</code> gives the first element.</p> <p>similarly for the declaration</p> <pre><code> int x[10][20]; </code></pre> <p>what kind of variable is <code>x</code> here. When i do </p> <pre><code> int **z = x; </code></pre> <p>the compiler says it cannot convert <code>int (*)[20]</code> to <code>int **</code>.And why does <code>cout&lt;&lt;x;</code> and <code>cout&lt;&lt;*x;</code> give the same value?? And also if i declare an array of pointers as </p> <pre><code> int *p[10]; </code></pre> <p>then is there a difference between <code>x</code> and <code>p</code> ( in their types) ?? because when one declares <code>int x[10]</code> and <code>int *p</code> then it is valid to assign <code>x</code> to <code>p</code> but it is not so in case of two dimensional arrays? why? Could someone please clear this for me or else provide a good resource material on this.</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.
 

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