[net.lang.c] DeSmet C bugs -- a != &a00

janney@unm-cvax.UUCP (06/21/84)

Note to net.lang.c readers: this started in net.micro.pc but I'm hoping
to move it to net.lang.c since I think it belongs there.  The question is, 
given the declaration
	double a[10][20];
is a the same as &a[0][0]?

I see I will have to elaborate on my previous posting.  It may have contained a
mistake: I referred to &a[0], and I'm not sure whether that means anything
in C.

A is not the same as &a[0][0], although they are very similar.  They both
point to the same place in memory, but they point to objects of different
sizes.  A is an array of 10 elements, each of which is an array of
20 doubles.  A, when used in an expression, denotes the address of the
first element of a, which is an array of 20 doubles.  &a[0][0] is the
address of the first (0th?) element of the first element of a, which is
a double.  The difference becomes important when you start doing pointer
arithmetic: a+1 is very different from &a[0][0]+1.

Section 5.10 of K&R has nothing to do with the case: the relevant part is
in section 5.7, on page 104, where it says: 
	"In C, by definition a two-dimensional array is really a
	one-dimensional array, each of whose elements is an array."

I suggest that followups, if any, go to net.lang.c.

Jim Janney
{{convex,ucbvax,gatech}!unmvax, {purdue,lbl-csam,cmcl2}!lanl-a}!unm-cvax!janney