c - Code is overwriting array -


is there problem these samples of code? whenever there x in spot still overwriting o in spot if win can made. apparently if not statement not working? 88 , 79 'x' , 'o' in ascii.

while(i+j<6)     {         if (board[i][j]+board[i][j+1] == compxo*2)         {             if(board[i][j+2] != (88||79))              {             board[i][j+2] = compxo;             won=1;             break;             }         }         else              i++;     }   if (board[i+1][j+1]+board[i+2][j+2] == compxo*2)     {            if(board[i][j] != (88||79))          {         board[i][j] = compxo;         won=1;          }     } 

you can't compare 2 different values @ once, expression 88||79 logical or, , evaluates 1, appropriate way is:

if(!(board[i][j] == 88 || board[i][j] == 79))  

or

if(board[i][j] != 88 && board[i][j] != 79) 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -