How is the array accessing values at indexes that are larger than its width. I thought when you go over the size limit it would throw a segfault error.
#include <iostream>
int main(){
const int len = 3;
const int wid = 3;
int arr[len][wid];
int count = 1;
// assigns array to numbers 1 - 9
for(int i =0;i < len;i++){
for(int j =0;j< wid;j++){
arr[i][j] = count++;
}
}
int index = 0;
// prints out the array
while(index < 9){
std::cout << arr[0][index++] << " "; // how is it accessing space that wasn't allocated? index++
}
std::cout << std::endl;
}