The array identifier of C does not contain the information of the array length, but only the address information, so the language itself cannot check it and can only be checked by the compiler. Early C language compilers did not check array out-of-bounds. , can only be checked and ensured by the programmer himself. In addition, in the early CRT functions, there was no out-of-bounds check on string pointers or arrays, which required programmers to ensure sufficient space. Therefore, there was a safe CRT function version provided by Microsoft after VS2005. Even if it goes out of bounds, it can be compiled normally. Try to expand the range and output the address at the same time. It can be seen that the out-of-bounds address is indeed accessed
It’s not that there are no problems, it just happens that there are no errors. You visited a space that doesn't belong to you, and no one happens to be using that space, so it seems fine.
The array identifier of C does not contain the information of the array length, but only the address information, so the language itself cannot check it and can only be checked by the compiler. Early C language compilers did not check array out-of-bounds. , can only be checked and ensured by the programmer himself. In addition, in the early CRT functions, there was no out-of-bounds check on string pointers or arrays, which required programmers to ensure sufficient space. Therefore, there was a safe CRT function version provided by Microsoft after VS2005. Even if it goes out of bounds, it can be compiled normally. Try to expand the range and output the address at the same time. It can be seen that the out-of-bounds address is indeed accessed
0x100500000
0x100509c40
1
Program ended with exit code: 0
It’s not that there are no problems, it just happens that there are no errors.
You visited a space that doesn't belong to you, and no one happens to be using that space, so it seems fine.