Reply to: C arrays: some oddities

utzoo!decvax!ucbvax!menlo70!sri-unix!gwyn at UTEXAS-11 utzoo!decvax!ucbvax!menlo70!sri-unix!gwyn at UTEXAS-11
Tue Jan 5 22:39:41 AEST 1982


My understanding of the intent of the language agrees with the Ritchie
compiler's, except that in the case
	type	array[SIZE];
	type	array2[SIZE1][SIZE2];
I would have expected &array and &array2 to be undefined (although I
think the Ritchie compiler does the right thing if they are defined).

	type	array3[SIZEA][SIZEB][SIZEB];
	array3 == &array3[0] == &array3[0][0] == &array3[0][0][0];
	array3[i] == &array3[i][0] == &array3[i][0][0];
	array3[i][j] == &array3[i][j][0];
is how I interpret "incomplete" array subscripting; I recommend writing
	&array3[0][0][0]	instead of
	array3
to make the C code less subject to interpretation by the reader (you get
the same generated code in either case, but the address of an array
element is the more familiar concept to most programmers).
-------



More information about the Comp.unix.wizards mailing list