Okay, so I was teaching my girlfriend some c++, and she wrote a program that I thought wouldn\'t work, but it did. It accesses one more element in the array then there is (f
It's undefined behavior. UB comes in many flavors. Here are a few:
1) It will kick your dog.
2) It will reformat your hard drive.
3) It will work without a problem.
In your case, with your compiler and on your platform and on this particular day, you are seeing (3). But try it elsewhere, and you might get (1), (2), or something else completely (most likely an access violation).