Array bounds checking with C????

Michael Meissner meissner at osf.org
Sat Sep 1 00:26:36 AEST 1990


In article <988 at christopher-robin.cs.bham.ac.uk> cjr at cs.bham.ac.uk
(Chris Ridd <RiddCJ>) writes:

|   Why is this?  I never could figure out why accessing the first
| element *past* the end of an array should be legal.

So that you can do something like:

char array[ARRAY_SIZE];

void clear_array(){
	char *p;

	for (p = &array[0]; p < &array[ARRAY_SIZE]; p++)
		*p = '\0';
}
--
Michael Meissner	email: meissner at osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

Do apple growers tell their kids money doesn't grow on bushes?



More information about the Comp.lang.c mailing list