A second Google search yielded the following:
The K&R method of reducing arrays to pointers
K&R tried to create a unified treatment of arrays and pointers, one that
would expose rather than hide the array equation in the compiler code.
They found an elegant solution, albeit a bit complicated. The "ugly"
array equation is replaced in their formulation by four rules:
1) An array of dimension N is a 1D array with
elements that are arrays of dimension N-1.
2) Pointer addition is defined by:
ptr
"#" denotes here pointer addition to avoid
confusion with ordinary addition.
The function "size()" returns object sizes.
3) The famous "decay convention": an array is
treated as a pointer that points to the
first element of the array.
The decay convention shouldn't be applied
more than once to the same object.
4) Taking a subscript with value i is equivalent
to the operation: "pointer-add i and then
type-dereference the sum", i.e.
xxx[i] = *(xxx # i)
When rule #4 + rule #3 are applied recursively
(this is the case of a multi-dimensional array),
only the data type is dereferenced and not the
pointer value, except on the last step.
Source
source
share