Is &a[NTHINGS] legal

Brad Daniels biff at eyeball.ophth.bcm.tmc.edu
Fri May 6 08:11:21 AEST 1988


In article <12074 at tut.cis.ohio-state.edu> lvc at tut.cis.ohio-state.edu
(Lawrence V. Cipriani) writes:
>Is it legal to apply the & (address of) operator to an array
>element that is non-existent?  Given:
>	sometype a[NTHINGS], *p;
>Should:
>	for (p = a; p < &a[NTHINGS]; p++)	/* 1 */
>		...
>be written as:
>	for (p = a; p <= &a[NTHINGS-1]; p++)	/* 2 */
>		...

Whether or not the above is legal, I think it should probably be written as:

	for (p = a; p < (a+NTHINGS); p++)

Or am I missing something obvious?

					- Brad
-
Brad Daniels			|	biff at eyeball.ophth.bcm.tmc.edu
The Low Vision Project		| If money can't buy happiness
Baylor College of Medicine	| I guess I'll have to rent it.  - Weird Al



More information about the Comp.lang.c mailing list