< Previous | Contents | Next >

The opponent() Function

This function gets a piece (either an ’X’ or an ’O’) and returns the opponents piece (either an ’X’ or an ’O’).

char opponent(char piece)

{

if (piece == X)

{

return O;

}

else

{

return X;

}

}