Arrays and Pointers

6. Arrays and Pointers

6.1I had the definition char a[6] in one source file, and in another I declared extern char *a. Why didn't it work?

6.2But I heard that char a[] was identical to char *a.

6.3So what is meant by the ``equivalence of pointers and arrays'' in C?

6.4Whyare array and pointer declarations interchangeable asfunction formal parameters?

6.7How can an array be an lvalue, if you can't assign to it?

6.8Whatis therealdifference between arrays and pointers?

6.9Someone explained to me that arrays were really just constant pointers.

6.11I came across some ``joke'' code containing the ``expression''5["abcdef"] . How can this be legal C?

6.12What'sthe difference betweenarray and &array?

6.13How do I declare a pointer to an array?

6.14How can I set an array's size at compile time?

6.15How can I declare local arrays of a size matching a passed-in array?

6.16How can I dynamically allocate a multidimensional array?

6.17Can I simulate a non-0-based array with a pointer?

6.18My compiler complained when I passed a two-dimensional array to afunction expecting a pointer to a pointer.

6.19How do I write functions which accept two-dimensional arrayswhen the ``width'' is not known at compile time?

6.20How can I use statically- and dynamically-allocatedmultidimensional arrays interchangeably when passing them to functions?

6.21Why doesn't sizeof properly report the size of an array which is a parameter to a function?


top