[net.micro.pc] DeSmet C bugs -- a != &a00

bet@ecsvax.UUCP (06/19/84)

I am surprised to hear this bug report -- I am pretty sure my othello
program would have been broken if this existed (but maybe that's where
it gets its inspiration). I will certainly have to try it out; could
the poster of the original note please post or mail me a compilable
fragment that demonstrates the problem?

Re the response that "a isn't supposed to be equal to &a[0][0]" this
is a surprisingly common misconception resulting from failing to read,
and re-read, and then study some more section 5.10, page 110 in K&R.

					Bennett Todd
					...{decvax,ihnp4,akgua}!mcnc!ecsvax!bet

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