Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You are mistaken (as is _delirium). Pointers to arrays are fundamental to how multi-dimensional arrays are implemented in C, and this question is designed to test your understanding of them. (It is most certainly not about a fancy way of getting a pointer to the first element after the array, since this pointer has a completely different type.)

Multidimensional arrays are arrays of arrays, not arrays of pointers to arrays (as in Java). Therefore when manipulating, say, rows of a 2-dimensional array you are dealing with pointers to arrays like &x in this example.

It's not an every-day thing but it does come up, and in some specialised fields no doubt it is very common.



> (It is most certainly not about a fancy way of getting a pointer to the first element after the array, since this pointer has a completely different type.)

Have to be careful there. Going more than one after the end of the array is undefined (see 6.17):

http://c-faq.com/~scs/cgi-bin/faqcat.cgi?sec=aryptr

Actually, that whole FAQ should be of interest to anyone who liked this article. No matter how many times I read through it, I seem to find something new.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: