The first thing I see is a probable out-of-bounds access:
if(Chess[x -1 ][y -1]== 1&& x>=1 && y >=1 )
What if the value of x
is 0
? You are accessing Chess[-1][y], which is out of bounds. Your if
statement does not stop this, even with the x>=1
condition.
The if
will first test the Chess[x-1][y-1]==1
condition. If you want this to not happen, place the test for x>=1
before Chess[x-1][y-1]==1
.
But even with this, that entire section of code looks suspicious. I wouldn't be surprised if there were more out-of-bounds accesses.