Why don't I get a segmentation fault when I write beyond the end of an array?
问题 why is this not giving error when I compile? #include <iostream> using namespace std; int main() { int *a = new int[2]; // int a[2]; // even this is not giving error a[0] = 0; a[1] = 1; a[2] = 2; a[3] = 3; a[100] = 4; int b; return 0; } can someone explain why this is happening. Thanks in advance.) 回答1: I'm guessing you're coming from Java or a Java-like language where once you step out of the boundary of an array, you get the "array index out of bounds" exception. Well, C expects more from