how has C bitten you?

preece at ccvaxa.UUCP preece at ccvaxa.UUCP
Tue Aug 6 01:44:00 AEST 1985


> > 	int i, a[10];
> > 	for (i = 0; i <= 10; i++)
> > 		a[i] = 0;
> > 

> This looks to me like it will simply overwrite one int's worth of
> memory beyond the end of the array "a" with the value 0.  Granted,
> depending on what happens to be after "a", this can have disastrous
> results, but is there really an implementation in which it will
> (reliably) lead to infinte looping?
----------
Yes.  Any implementation that allocates the space for i following the
space for a.



More information about the Comp.lang.c mailing list