I wonder if pointers confuse people because C's syntax for pointers is confusing. The confusing examples always involve arrays, where a statically allocated array's behavior is different from one that's dynamically allocated and not necessarily what you would expect as a beginner, or where the vagaries of operator precedence obfuscate the pointer arithmetic.<p>I think the C++ programming book I first used made it worse by equating pointers and arrays from the start, making it seem like they were interchangeable.<p>At least for me, no other languages including assembler seemed to generate this amount of confusion over such a simple thing.
Further clarification from the C FAQ:<p><a href="http://c-faq.com/aryptr/aryptrequiv.html" rel="nofollow">http://c-faq.com/aryptr/aryptrequiv.html</a><p><a href="http://c-faq.com/aryptr/aryvsadr.html" rel="nofollow">http://c-faq.com/aryptr/aryvsadr.html</a><p><a href="http://c-faq.com/aryptr/aryptr2.html" rel="nofollow">http://c-faq.com/aryptr/aryptr2.html</a>
The Butt-Ugly Fish Book has a great section on this: <a href="http://www.amazon.com/Expert-Programming-Peter-van-Linden/dp/0131774298/" rel="nofollow">http://www.amazon.com/Expert-Programming-Peter-van-Linden/dp...</a><p>In fact it's filled with great sections - go read it if you haven't.
If you enjoy this kind of puzzle "The C Puzzle Book" if full of them with a clear explanation: <a href="http://www.amazon.com/Puzzle-Book-Alan-R-Feuer/dp/0201604612" rel="nofollow">http://www.amazon.com/Puzzle-Book-Alan-R-Feuer/dp/0201604612</a><p>It's a funny little book that can keep you busy during compilation time.<p>And the "C Reference Manual" (<a href="http://www.careferencemanual.com/" rel="nofollow">http://www.careferencemanual.com/</a>) is the best, up-to-date reference to understand how this small language can be abused.
If it had declared<p><pre><code> struct { int x[4] } s;
</code></pre>
...then &s, &s.x and s.x would all evaluate to the same address, but with three different types.
That seems like an odd feature. I mean, useful in some cases where the size of the array is statically determined, but kind of fiddly and not the same across such unusual things as function calls.
printf("%p\n", (void*) (&x + 1));<p>News flash: it's easy to confuse people such as myself who don't know, and don't care, whether the & unary operator is above or below the + binary operator in the precedence hierarchy. Anyone who writes an expression like this without parentheses has been educated beyond their wisdom. Ric has more at 11.