Quote:
Changing it to vertices[3000] didnt change anything.
It shaved off a little undefined behaviour, which is always a good thing. When you wrote to vertices[2999], you were overwriting some piece of memory.
Think about it. An integer array with one element has a declaration:
int array[1]; and its only element is at:
int x = array[0];. For two elements, the declaration is
int array[2]; and the elements are at
array[0] and
array[1].
Logically adding N to this and generalising the types you can see that for a declaration of
Type array[N]; you can index to
array[0] to
array[N - 1].