J
James Kanze
[...]"An array always evalues ("decays") to a constant pointer to its
first element, except as the operand of sizeof or of the unary &.
For example, given:
int arr[100];
int * const ptr = &arr[0];
Every expression containing arr will have the same identical value
that it would have if arr were replaced with ptr, unless arr is
used as the operand of & or sizeof."
Too complicated for students? If so, you'd better teach those
students some other language.
You forgot one case: a string literal used to initialize an array
doesn't decay to a pointer.
Sort of. He did say "evalues". Maybe (probably?) he meant by
that "when used in an expression". After all, the first use of
arr in his example doesn't decay to a constant pointer; "int
arr[100]" is a very different beast than "int *const arr;". And
initialization of an array of char with a string literal is
arguably a special case, where the initializer is not an
expression (although that's not quite the way I'd explain it).
Anyway, my point is that you can't talk about arrays and
pointers in expressions without first talking about declaring
them, so you have to start with their being different things;
you can't avoid it.