pointers to arrays
Guy Harris
guy at auspex.UUCP
Tue Feb 21 05:13:36 AEST 1989
>AUUUGH!
Yeesh. Stop screaming, and please get either a copy of the pANS or of K&R
Second Edition, and read it, before discussing this issue any further.
This stuff really will work reasonably, whether you believe it yet or not.
>what happens if you say (*foo) = muck (where muck is int muck[13])
The compiler, if it's at all good, says "sorry, the left-hand side isn't
a valid lvalue, try again". No, (d)pANS C doesn't support array
assignment.
>(Long discussion which assumes that, if you can get a pointer to an
>array you *must* be able to assign to it as a whole, and thus concludes
>that "pointer to array" is an invalid concept)
No, just because you can get a pointer to an array (BTW, C has supported
the notion of "pointer to array" for quite a while, it just made it
inconvenient to construct certain values of that type until (d)pANS C
allowed you to stick & in front of an array-valued expression) doesn't
mean you can put an array on the LHS of an assignment; not all things
you can apply the & operator to are lvalues.
Again, *please* get a copy of, say, K&R Second Edition, and read it
thoroughly before commenting any further. Unfortunately, you'll have to
read the "C Reference Manual" appendix for this stuff; there doesn't
seem to be much in the way of tutorial information on the notion of a
pointer to an array.
More information about the Comp.lang.c
mailing list