Recent C Puzzle & using pointers in arrays

utzoo!decvax!cca!alex utzoo!decvax!cca!alex
Thu Nov 11 11:37:35 AEST 1982

My apologies to those of you who are seeing this again:

Back when we used to use the 11 cc compiler, it was quite legal to do
the following:

	int *foop;
	int fooarray[SOMESIZE];

	for (foop = fooarray; foop < &fooarray + 1; foop++) {
		*foop = somevalue;

This worked because the 11 C compiler scaled 1 to the size of the
array when an ampersand was used in front of the array name.  Whether
such a construct is TRULY USEFUL in C is an interesting debate, which
I am herewith starting.  I claim (for the sake of this debate) that it
is useful to have a general and unambiguous way to reference the end
of any object.  While we all know that the semantics of C arrays could
be improved, and the notation used above was mostly a kludge, I find
using pointers in this manner a useful paradigm in programming.

The pcc, of course, dislikes & before arrays.  Note that the ampersand
is necessary above, since without it, the scale factor is an element
of the array instead of the whole array.

					Alexis Layton
					Computer Corporation of America
					alex @ CCA-UNIX

More information about the Comp.lang.c mailing list