Answer

The program probably printed out 30 elements, 20 of which were garbage. If you ask C to read or write beyond the ends of an array, it will try to comply. If you are reading, it will give you the contents of some other piece of memory. If you are writing, it will change the contents of some other piece of memory, probably causing a problem elsewhere in your program.

Return to lesson.



Eric N. Eide
Hamlet Project
Department of Computer Science
University of Utah