0

I made an array with 10 rows and 2 columns. Then I tried to access the element at the 100th row and 100th column. Why does this not give me an error:

#include <iostream>

int main () {
    int (*myarr)[2] = new int[10][2]();
    std::cout << myarr[100][100];
}
KugBuBu
  • 630
  • 5
  • 21
Darvish Kamalia
  • 817
  • 1
  • 7
  • 19

1 Answers1

0

That would result in an undefined behavior. That means you could get a crash OR your program won't do anything.

Standard never said that you must get crash for that.

ravi
  • 10,994
  • 1
  • 18
  • 36