int a[10];
std::cin >> a[12];
std::cout << a[12];
Shouldn't the a[12]
line raise an error as the array is only declared for 10 indexes? Is there something obvious I'm missing, or has it always been like this?
int a[10];
std::cin >> a[12];
std::cout << a[12];
Shouldn't the a[12]
line raise an error as the array is only declared for 10 indexes? Is there something obvious I'm missing, or has it always been like this?
You are free to index out of range, but it is undefined behavior. This could eventually manifest in memory stomping, a write access error, or other.