pointer to array c++
<p>My understanding about assigning an array to a pointer is that the pointer is pointing at the first  index of the array, so when printout the pointer, it should print out the address of the first index of the array, but how come in this case the <strong><em>cout</em></strong> printed out the value of the whole array? even though I explicitly indicated that I wanted the address of the first index</p>

<pre><code>char foo[] = {'A','B','C','\0'};
char* p = foo;
char* q = &amp;(foo[0]);
cout &lt;&lt;"from p:  " &lt;&lt; p &lt;&lt; endl;
cout &lt;&lt; "from q: " &lt;&lt;  q &lt;&lt; " " &lt;&lt; &amp;(foo[0]) &lt;&lt;  endl;

//output
from p:  ABC
from q: ABC ABC
</code></pre>

<p>the second question is that I see the difference between those two lines is that one is an array of pointer to char, the other is a pointer to a char array, is that correct? is the parenthesis necessary? </p>

<pre><code> char* bar1[4];
 char (*bar2)[4] = &amp;foo;
 cout &lt;&lt; "address of foo is  " &lt;&lt; bar2  &lt;&lt; endl;
 //output
 address of foo is  0x7fff192f88b0
</code></pre>

<p>The address of the foo array should be the same as the address of <strong><em>A</em></strong>, right? How do I printout the address of A? since I failed to do so. Thank you very much </p>
