jeudi 12 août 2021

Why I am not getting array out of range error? [duplicate]

I have a problem of understanding. Why does this code work? I would now expect to get an out of range error.

int testArray[2][2];

testArray[0][0] = 1;
testArray[0][1] = 1;
testArray[1][0] = 1;
testArray[1][1] = 1;

testArray[1][5] = 5;
std::cout << testArray[1][5];

I am using Visual Studio 2019. I am getting a warning but on the console the correct value is still displayed.

Aucun commentaire:

Enregistrer un commentaire