In high-level languages, there are functions that prevent you from accessing outside the bounds of an array, by generating an exception (for example, ArrayIndexOutOfBoundsException
in Java).
In C, however, arrays are pretty primitive - they are just a sequence of elements with contiguous addresses. There are no bounds checking because it is simply exposing raw memory.
Accessing an invalid index of an array results in Undefined behavior (which essentially means that C simply says what should happen if you access the elements within the bounds of an array. It is left undefined what happens if you try accessing out of bounds. It might work today but it is not legal C, and there is no guarantee that it'll still work the next time you run the program).
It is therefore your responsibility as a developer not to shoot yourself in the foot.