Accessing part of an array that doesn't exist
piguy101
Posts: 248
Suppose that I had an array of ten bytes called memory. So: byte memory[10]. What would happen if part of the code tried to set or read parts of the array that do not exist such as memory[11]:=0 or x:=memory[11]? My guess is that the first code would not do anything and x in the second code would be set to zero. Is this correct?
Comments
Then
would have the same effect as
Remember with ten elements in the array, the highest index is 9 (since they start with zero).
So:
would have the same effect as
If you use
Then you're in danger of overwriting your program.