### find empty inventory slots

I made two dimensional array to represent my (game) inventory.
Slot is empty if its value is 0 and 1 if not.
Now i need to find if i can put new item in my inventory that can take up 4x2 slots. I tried this but it doesn't work as i expected:

 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 #include int main() { const int inventorySlotRows = 5; const int inventorySlotColumns = 5; int arr[inventorySlotRows][inventorySlotColumns] = { { 1, 1, 1, 1, 1 }, { 0, 1, 1, 0, 1 }, { 1, 0, 1, 0, 0 }, { 1, 0, 0, 0, 0 }, { 1, 0, 0, 0, 0 } }; // needed empty slots for new item int emptySlotsRows = 4; int emptySlotsColumns = 2; bool have = false; for(int i = 0; i < inventorySlotRows; ++i) { for(int j = 0; j < inventorySlotColumns; ++j) { if(0 == arr[i][j] && (i + emptySlotsRows) <= inventorySlotRows && (j + emptySlotsColumns) <= inventorySlotColumns) { int sum = 0; for(int k = 0; k < emptySlotsRows; ++k) { for(int l = 0; l < emptySlotsColumns; ++l) { sum += arr[i+k][j+l]; } } have = (sum == 0) ? true : false; } } } std::cout << std::boolalpha << have << std::endl; return 0; };

How would you do this?