As someone already pointed out in the comments, I'm not sure if your if
conditions are doing what you think they're doing.
if(TABLE[0][0] && TABLE[0][1] && TABLE[0][2] == P1_SIGN){ //prima riga
puts("PLAYER 1 WINS
");
End = -1; //valore di vincita
}
At the moment this piece of code, for example, is checking if TABLE[0][0]
and TABLE[0][1]
are (EDIT:) !=0
and if TABLE[0][2]
is equal to P1_SIGN
. If this is how it supposed to work it's fine, either way you should change all your if
like suggested in the comments (by @MikeCAT).
Another important thing is how you're using your function. You're returning a value (End
) but not storing it anywhere, so you should do:
int result = Verify_Win_Or_Tie(TABLE, P1_SIGN, P2_SIGN, End, Counter_Obj);
Or, if you prefer to use pointers:
/* function now returns void */
void Verify_Win_Or_Tie(char TABLE[][T], char P1_SIGN, char P2_SIGN, int* End, unsigned int Counter_Obj) // now End is a pointer to int
{
if(TABLE[0][0] && TABLE[0][1] && TABLE[0][2] == P1_SIGN){ //prima riga
puts("PLAYER 1 WINS
");
// updating pointed value
*End = -1; //valore di vincita
}
/* rest of code */
}
How to use it on main:
Verify_Win_Or_Tie(TABLE, P1_SIGN, P2_SIGN, &End, Counter_Obj); // passing address of End
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…